Internationalisation

Coming Soon

The internationalisation module provides facilities for multi-lingual/multi-culture sites. Included features are:

  • A content item can have versions in any of the supplied culture codes. These are accessed by using a url with an element which represents the culture via a routing key.
  • Filtered or selected lists of content items can be copied from one culture version to another.
  • A tag helper for a select list for switching language/culture
  • A phrase translator for static text in templates: enter a dictionary of base language phrases against translations into other languages.

Setting up the Internationalisation module

For database data sources, the internationalisation module requires adding the Locale field to the ContentItems table. This can be done by running the script at /Areas/Lynicon.Base/Admin/SQL/InternationalisationInit.sql.

Configuring Internationalisation

.UseModule<I18n>((Func<Type, bool>)(t => t != typeof(User)), "locale", "en-GB", new Dictionary<string, string> { { "en-GB", "UK" }, { "es-ES", "España" } })

The internationalisation has the following arguments when set up:

  • the appliesToType argument which is a function from Type to bool where the type is a container type and the result is true if this container type is cached.
  • the localRouteKey argument which contains the name of the route key which contains the locale indicator: this must be specified on any route to multi-locale content.
  • the defaultLocale argument which specifies which is the default locale
  • the localeDict argument which is a Dictionary<string, string> of the possible locale codes as keys against the friendly names of the locales.

Managing Locale Versions

Generally content will be created in a base language and then translated into different locale versions. The filter page provides the means for doing this, allowing a selected list of content items in a locale version to be copied to another locale version. Setting up the I18n module adds a drop-down list of locales and a button captioned Copy to Locale at the bottom of the results list. This copies all selected items to the selected locale.

Other useful procedures can be done using the filter page with a little thought. For example, to find content items which have not been modified since they were copied to a locale version (and so still need translation) use the Created When and Updated When filters, setting both Show checkboxes to true. You can then inspect the created and updated dates of the items and if these are the same, they will not have been edited.

While working in the content editor, setting up the module will add a new version changer to allow you to switch between language versions:

Adding the Internationalisation module to a Site with Existing Content

Initially all records will have a Locale field value of null. This value means the record occupies all locale versions and appears on all distinct locale urls. As soon as it is copied to a specific locale, the original record becomes assigned to the current locale and a new record is created assigned to the copied to locale. Any locales beyond these two will be empty at this point and will return a 404.

Translation of Static Text in Templates

While having locale versions of content data allows for translation of this data, there will also be certain data such as headings, labels and captions on a page that are shown for all pages using a given template. There are 3 options for dealing with this text:

  • The built in Resource Files system in .Net
  • Adding content properties for these headings etc and using PropertyRedirectAttribute to make these properties shared across all content items of the same type and the same locale version (see Sharing and Combining Content Data)
  • Using the Dictionary system which comes with the Internationalisation module

The first option has the advantage of being a .Net standard, but it is quite low level to work with and has no direct means for translators to do their translations on publically available web forms.

The second option is a little awkward and requires both adding content properties and replacing the static text in templates with property markers.

The third option is in our view the easiest to work with. Adding the Internationalisation module adds a UI for creating a content item type called TranslationDictionaryEntry. This list/detail editor can be accessed at /Lynicon/Dictionary or via the Dictionary button which the I18n module adds to the navigation bar at the bottom in editing mode.