This document describes how localisation is implemented in RDMP. The design follows the approach set out by Microsoft.
Localisation is in its infancy in RDMP, the framework is in place but no serious work has been undertaken. We would welcome the opportunity to work with any interested parties on fully implementing the approach set out in this document.
All user visible strings in RDMP should be moved to GlobalStrings.resx
Language specific strings should appear in GlobalStrings.[language].resx e.g. GlobalStrings.zh-Hans.resx
Most icons in RDMP are 19x19 png files. These are stored in CatalogueIcons.resx and FamFamFamIcons.resx. These resources files support language specific overriding in the same manner as with strings (above) e.g. CatalogueIcons.zh-Hans.
Each language should store these images in its own subdirectory e.g. zh-Hans
Since there are lot of strings in RDMP we will need to follow to ensure maintainability.
Where multiple strings are related they must have the same root e.g.:
- CreateArchiveTableCaption
- CreateArchiveTableYesNo
- CreateArchiveTableSuccess
Where a string includes reference to a dynamic value e.g.
"Table Bob did not exist"
It should be stored in the resource file(s) as:
"Table {0} did not exist"
This allows it to be used with String.Format
All menu items in RDMP should be modelled as a IAtomicCommand
. This class has the following methods which should be implemented:
public class ExecuteCommandCreateNewCatalogueByImportingFile:BasicUICommandExecution, IAtomicCommandWithTarget
{
...
public override string GetCommandHelp()
{
return GlobalStrings.CreateNewCatalogueByImportingFileHelp;
}
public override string GetCommandName()
{
return GlobalStrings.CreateNewCatalogueByImportingFile;
}
}
The resource property name(s) should match the command name.
There are cases in RDMP where the string values of Enums are used. Use the extension method S()
to display a culture specific (if exists) string.
For example
MessageBox.Show("Status was:" + TriggerStatus.Disabled.S());
You can test localisation by adding the following to Program.cs
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans");
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-Hans");
Visual Studio plugin ReSharper shows missing translations and there are many good tools for interacting with resx files (even those aimed at translators rather than programmers) so the amount of unit testing we need to do should be quite limited.
- We should write a test that confirms that all commands with tokens ({0},{1} etc) have the same number of distinct tokens in all languages (implementing overrides)
- Maybe we can make
EvaluateNamespacesAndSolutionFoldersTests
detect incorrect usages ofShow
,YesNo
where params don't match the number of {x} tokens too
- RDMP makes xmldoc comments visible through the UI (via
CommentStore
). Localising this will be difficult.