Scope: managed applications, mobile applications, and ordinary applications.
1. If you use binary templates to store data to be translated in another language (hereinafter, the template), in the template name, specify a postfix consisting of the underscore and the language code as it is specified in metadata, in the Russian language, in the Language code property: "_ru".
Incorrect:
template PF_ODT_ProformaInvoice (proforma invoice print form template in OpenOffice Writer format)
It is correct to include the postfix of the main language in the name:
template PF_ODT_ProformaInvoice_ru
In the code, depending on the language, use a template with an appropriate postfix. Incorrect:
... = GetCommonTemplate("PF_ODT_ProformaInvoice");
Correct example:
... = GetCommonTemplate("PF_ODT_ProformaInvoice" + "_" + CurrentLanguage());
To avoid errors upon partial translation of the configuration, it is recommended that you get a template in three stages:
- First, by TemplateName + "_" + CurrentLanguage();
- If the template is not found, search for it by TemplateName + "_" + Metadata.MainLanguage.LanguageCode;
- If it is not found, search for it by the passed TemplateName.
2. When you need to get data programmatically from a spreadsheet, text or HTML template in a specified language that differs from the interface language of the current user, use the LanguageCode property (available for spreadsheet documents) and the TemplateLanguageCode property (available for text documents and HTML templates in 1C:Enterprise 8.3.10 or higher). For example, if a print form is generated in a language that differs from the interface language of the current user.
Correct:
Template = GetCommonTemplate("PrintForm"); Template.TemplateLanguageCode= "en"; HTMLDocument = Template.GetHTMLDocument();
3. In names of spreadsheet or HTML templates that are to be displayed to users or printed only in a single language, regardless of the enabled interface language of the current user, the country where the application or configuration is used, or the user data language, specify a language code postfix similarly to cl. 1 and set a template language code similarly to cl. 2 upon getting the template programmatically in the code. Such templates are not to be translated into other interface languages. When generating texts for filing in templates programmatically, explicitly specify the second parameter of the NStr() function. So, strings will be generated in the same language as the template. An example of such templates are compliance reporting print forms for government institutions in a specific country.
Incorrect example:
Template = GetTemplate(("PF_MXL_TaxInvoice"); ... Region.Text= NStr("en='Print title',");
Correct:
Template = GetTemplate(("PF_MXL_TaxInvoice_en");
Template.LanguageCode = Metadata().Languages.Russian.LanguageCode;
...
Region.Text = NStr("en='Print title';", Metadata().Languages.Russian.LanguageCode);
When Standard Subsystems Library (SSL) and the Printing subsystem are used, get a template via the PrintManager function. PrintFormTemplate("PF_MXL_TaxInvoice") is used to get the PF_MXL_TaxInvoice_en form if the main language of the application or configuration is English. It also sets the LanguageCode property of the template according to the used language.
4. If named insert parameters are used in template texts, make sure that they meet localization requirements for interface texts in the code.
5. Use the UTF-8 encoding in templates.
6. Group templates of the same type when possible (use a single template instead of several ones). In the example below, the configuration contains several similar templates with messages. Their content is written to one catalog. Therefore, it is correct to store such messages in one template.
Incorrect:
Template = DataProcessors.SwitchModes.GetTemplate("Message");
Correct:
Template = Data processors.SwitchModes.GetTemplate(StringFunctionsClientServer.SubstituteParametersToString("Messages_%1", Common.DefaultLanguageCode()));
7. Place add-ins in templates of the Add-in type. When you develop an add-in, process the SetLocale method to localize the add-in in accordance with the obtained localization code (see Add-in creation technology). If the obtained localization code differs from the one used in the add-in, the add-in must configure its environment to use English.