Localize XSLT functions and templates on your website
When used, Composite.Tools.FrontendLocalizer scans the functions and templates for strings. It creates an entry in an ad-hoc resource file (.resx) for each string found, and replaces the string in the functions and/or templates with a reference to this string entry. In this way, all the strings are stored externally and used by reference where appropriate.
If you have a localized version of your website, you can create a copy of the localization resource file (generated by the package) using the corresponding culture code in its name (e.g. "da-dk") and translate the strings in this culture-based file into the language of your localization.
When a visitor switches to the localized website, all the strings on pages from XSLT functions and templates will be localized.
How to use Composite.Tools.FrontendLocalizer
- Install the package.
- In your web browser, open the
http://localhost/FrontendLocalizer.aspxpage. Be sure to replacelocalhostin the URL with the name of your server. - Enter the name for your localization resource file ("Localization" by default)
- Click Localize.
You can further edit the generated file or create its localized versions for translation.
How to localize strings for XSLT functions and templates
To localize XSLT functions and templates:
- Create a resource file as described in the procedure above.
- Create a copy of this file in the
App_GlobalResourcesfolder adding the proper culture code between the file's title and its extension. For example, if you haveLocalization.resxcreated for your default website in English, you should name its copy for the Danish version of the website asLocalization.da-dk.resx. - Translate the strings in the localized file. You can open it in Visual Studio and use its resource editor or directly edit the XML content by locating each
<data>element and translating a text string within its<value>child element. For example,
<data name="NameLabel" xml:space="preserve"> <value>Navn</value> </data>
- Save the file.
When a visitor switches between the localized versions of your website, all the strings supplied by XSLT functions and templates on pages will be in the proper language.
Important notes
- Frontend Localizer creates a backup of the templates and XSLT functions used on the website every time, you generated the localization resource file. All the backups are stored at:
~/App_Data/Backups/FrontendLocalizer. You can use these backups to roll back to "non-localized" versions of templates and XSLT functions. - For any new strings on your website supplied by new or modified XSLT functions and templates, you need to re-run the tool again. The newly created file will only contain new strings. You should further make a copy of the file for localization and translate strings.
- Every time you run the tool, you should specify a new filename for the resource file. The existing file cannot be overwritten.
- You can manually add strings to the main and localized versions of the generated resource files and use references to them in your XSLT functions and templates following the syntax:
"Resource, Resources.<resource_file_name>.<string_name>"where<resource_file_name>is the name of the resource file without the culture code (e.g. "da-dk") and extension ("resx") and<string_name>is the name of the string in the resource file (for example, "Resource, Resources.Localization.TitleLabel".) - Frontend Localizer creates resource files in the
App_GlobalResourcesfolder on your website. All the resource files created manually should be also placed in this folder.
Related information
Requirements
Composite C1 version 2.0 SP 1 or later