Skip to end of banner
Go to start of banner

Custom Language/Internationalization in Core

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current Restore this Version View Version History

« Previous Version 15 Next »

Disney language:
- .net language must be installed on machine which builds the solution - if not - it doesn't generate the satellite localization dlls.
Even though the resx files are included into the main dll, the app (web) doesn't access them.
- Create dll which just does the language registration so we can use a powershell script to execute on build (build action).
Check in the custom culture generator dll to 'lib'
Visual Studio - restart to let VS update the .NET language list (especially removing a language)

Sisulizer Tool

We have one license of the software (currently installed on Stefan-PC). It creates translations (resx files) for Visual Studio solutions. Every custom language (i.e. en-US-Disney) needs it's resource file, generated by Sisulizer (translation resx file).

Install Sisulizer Tool

Either download the tool from https://www.sisulizer.com (Professional Developer version) or get it from network share \\mlsnas\Public\Software\Sisulizer Tool

License key can be found in https://docs.google.com/spreadsheets/d/1eOP-rSso_CzctFzv29Hp-Lw5EIalz72Ym6EE3lEzQzA/edit#gid=711274036

Create Language Variant in Sisulizer

A language variant is a custom language other than already existing .NET languages like 'en' or 'en-US'. A language variant is always created from a country specific language like 'en-US' - something like 'en-US-Disney'. No language variant can be created from 'en' only.

  • Open Sisulizer project file /src/MarineLMS - Sisulizer Translation.slp
  • Add a new language variant (Tools → General... → Languages)
    • Select a specific language you want to create a variant for and click 'Add variant...'.
      • Important: you must select a country specific language like en-US. You can't select just 'en'.
    • Tab Codes: add name for the ISO variant (i.e. Disney). Don't change the Windows code (which is autom. updated if the ISO variant name is added)
    • Tab Names: add the same variant names in both text fields as ISO variant (i.e. Disney)
    • The resulting custom language will be like EN-US-Disney
    • Continue with steps in 'Add Language to Core'

Add Language to Sisulizer and Core

To add a language (i.e. en-US, fr-CA) or language variant follow the steps below.

  • Open Sisulizer project file /src/MarineLMS - Sisulizer Translation.slp
  • Open drop down list for languages in tool bar and select Add...
  • Select any language from the list in 'Available languages' and move it to the list of 'Selected Languages' (via blue arrow button)
    • If you add a country specific language (i.e. FR-CA) and the general language (i.e. FR) is not added, a warning is issued. Select No
       
  • Select OK to complete adding a new language
  • Export translation resx files for the added language into VS solution via Project → Build in Selected Language → ..\src\MarineLMS.sln
  • Manually add all new translation resx files to the VS solution by including the generated translation resx files into the VS solution (right click on resx file and select 'Include in Project')
    • Always set the Custom Tool = PublicResXFileCodeGenerator and Custom Tool Namespace for each translation resx file to match the default resx file
  • Add the new translation resx files to Git
  • Check in/update the Sisulizer configuration file ('MarineLMS - Sisulizer Translation.slp' and 'MarineLMS - Sisulizer Translation.sds') into Git
    • Note: the 'MarineLMS - Sisulizer Translation.sds' file is updated once Sisulizer is closed

Update Resx Files and/or Create Translations for Core

  1. Open Sisulizer project file /src/MarineLMS - Sisulizer Translation.slp
  2. Project → Scan for Changes 
  3. Select All to view all text which can be translated.
  4. Ctrl + F5 to search for any term you need to translate
  5. Make any translation/changes you need
  6. Project → Build in Selected Language will generate updated/new translation resx files
  7. Save the Sisulizer project
  8. Open MarineLMS solution in Visual Studio
    1. Include newly created translation resx files (created by Sisulizer) to MarineLMS solution
      1. The easiest way to find any new resx files created by Sisulizer is to check Sourcetree for uncommitted changes/unstaged files
      2. In VS, right click resx file and select Include in Project (enable Show All Files in the Solution Explorer to find resx files which are not yet added to the solution)
    2. Update the newly added resx file's properties (2) to match the values of the default resx file
      1. Custom Tool: PublicResXFileCodeGenerator
      2. Custom Tool Namespace: [[namespace from corresponding default resx file]]
    3. Example: if you added the translation resx file AssessmentSummaryRx.en-US-Disney.resx, there is always a default resx file AssessmentSummaryRx.resx.
  9. Commit all resx files and the Sisulizer project files /src/MarineLMS - Sisulizer Translation.slp and /src/MarineLMS - Sisulizer Translation.sds (note: the sds file is updated once Sisulizer is closed)

Support Language Specific Date/Time Formats

In order to support different date and time formats for different locales all UI elements need to use the ILMSFormatter interface (class Formatters). The Formatters' Resx file contains date and time formats. Sisulizer context: MarineLMS.Web.Main\MarineLMS.Web.Main.csproj.Strings.MarineLMS.Web.Main.Util.FormattersRx.

Support Language Specific DatePicker

The Bootstrap date picker needs a separate js file for translations for different locales. For example bootstrap-datepicker.fr.min.js for French. The date picker doesn't support country specific language translations. That is, country specific languages like fr-CA and fr-FR would refer to fr only.

The following steps need to be done to add a new language to Visual Studio project Web.Main:

Use DatePicker in cshtml

The date picker classes data-date-format and data-date-language must exist and have the correct values.

div class="input-append date pull-left input-datepicker" data-date-format="@Model.DateFormatter.ShortDateAllNumbersFormat" data-date-language="@Model.DateFormatter.CurrentTwoLetterISOLanguageName" title="start date">

data-date-format: The date format for the DatePicker must contain numbers only - no month name like Jan or January is allowed.

data-date-language: The date language must be the 2 letter language name like en, fr,... The language name like 'fr' is deferred from the js script like 'bootstrap-datepicker.fr.min.js'.

Notes

Task  COREDEV-3930 - Getting issue details... STATUS  will change the DatePicker behaviour to truly use either local or UTC DateTime objects. However, the DateTime format for internationalization would still be required for UI purposes.

Handling Resx Files in Visual Studio

The MarineLMS.Web.Main project is currently the only project using resx files and translations with Sisulizer. Resx files in any other VS project are ignored. In general, you only need to pay attention to default (English) resx files in project MarineLMS.Web.Main. All translation (other language specific) resx files are maintained by Sisulizer. There are a few exceptions when adding new or removing resx files (see below for more details). Changes and updates of names/values within a translation resx file are ignored and overwritten by Sisulizer. Any update to a translation text must be done in Sisulizer instead. Having said that, changes to default resx files must be done in VS solution because Sisulizer uses all default resx files as truth (see 'Information Flow Between VS Solution and Sisulizer with Respect to Resx Files' below).

Sisulizer matches default resx values to allow translation of that value. That means a default resx value is treated as a read-only key by Sisulizer. If a resx file has moved but the values are the same, the translations known by Sisulizer remain and don't have to be translated again. However, if the default resx value changes, that value needs to be translated in Sisulizer as it shows up as a new (unknown) entry.

Important: Please let Stefan (stefan@marinels.com) know about any changes to/new resx files so he can run Sisulizer to update the translation resx files and get new text translated. This will keep Core up to date with any translations. 

Information Flow Between VS Solution and Sisulizer with Respect to Resx Files

Default resx files: VS solution is the authoritative truth and changes made to those resx files in VS solution are adopted into Sisulizer

Translation resx files: Sisulizer is the authoritative truth and changes made in Sisulizer are pushed into VS solution (overwriting any changes to translation resx files in VS solution)

Add new Default Resx File

If a new resx file needs to be added, only add the default resx file (i.e. AssessmentSelectorControllerRx.resx). Any translation resx files and their names/values are handled/created by Sisulizer (i.e. AssessmentSelectorControllerRx.fr-CA.resx and AssessmentSelectorControllerRx.en-US-Disney.resx).

Note: Sisulizer generates the translation resx files for any new default resx file. The translation resx files need to be added to the VS solution once (see Update Resx Files and/or Create Translations for Core).

Edit Existing Resx Name/Value

Only update the default resx file - updates to translation resx files are handled by Sisulizer.

Remove Resx File

Delete all resx files (default and translations) from the VS solution. Sisulizer will catch up on the changes because the default resx file was removed.

Note: If translation resx files were left in place they'd become orphaned because Sisulizer wouldn't delete or even read them once the default resx file was removed.

Rename or Move Resx File

Rename or move resx files can be done in two ways:

  1. Rename or move all resx files (default and translations) - if the default resx file was renamed, the translation resx files need to be renamed accordingly
  2. Rename or move default resx file only and delete all their corresponding translation resx files from the VS solution. Sisulizer will generate new translation resx files for the renamed/moved default resx file. However, follow the steps at Update Resx Files and/or Create Translations for Core to re-add the translation resx files to the VS solution again.

Trips and Pitfalls

  • Make sure that the default resx file and their translation resx files have the same Custom Tool Namespace and Custom Tool = PublicResXFileCodeGenerator (the designer resx file must exist)


Filter by label

There are no items with the selected labels at this time.