User Tools

Site Tools


translate_mail2voice

How to translate Mail2Voice?

Generalities

Mail2Voice native language is english, thus if no locale file exists, it will display in english.

The translation is made with locale files (using XML code). All locales files are in the locales folder and are named with the .lng extension. The reference file is english.lng so each locale file must translate every words/sentences that are in this reference file.

You must not modify the reference file (english.lng) directly (but it's OK for the others). If you want to modify the english translations, you will have to modify the source code of Mail2Voice and then follow the instructions from the next sections to generate the new english.lng file.

In a .lng file, there are two types of translations: the widgets labels and the vocal messages. The widgets labels are grouped by panel whereas all vocal messages are grouped in the “voiceSentences” section.

The translatable strings are the ones in the “value” tags and you must not change any other tags.

Note: the translations are sorted alphabetically in each section.

Write translatable strings in the code

The reference locale file (english.lng) must be generated when the source code of Mail2Voice is modified. This file is generated from the translatable strings found in the source code. We are taking into account two types of translatable strings: the widgets texts and the voice sentences.

Widgets

For Widgets, Mail2Voice is capable of translating the Text and TextHeader properties of any widget. So, when translating, it looks in the .lng file and translates these properties for each “setting” entry (except for the “vocalSentences” section of course).

There are two rules:

  1. Every translatable widget must be created in *.Designer.cs files.
  2. in your code, you must use the widget name as the widget variable identifier, like this:
  this.mailtoContactButton.Name = "mailtoContactButton";
  

Then you can add a Text or a TextHeader property to your widget:

  this.mailtoContactButton.Text = "Write";

When the reference locale file is generated, you will see a line like this in the english.lng file:

  
  <setting name="mailtoContactButton" value="Write" />

Vocal messages

Vocal messages work differently. First, unlike widgets, these messages must be created in *.cs files.

Then, in your code, you must register vocal messages like this:

  SpeechObject.Singleton.AddVoiceString("emailAddError", "You must specify an email to add this contact.");
  

The first parameter is the identifier of the string which will be used in the .lng file.

When the reference locale file is generated, you will see a line like this in the voiceSentences section of the english.lng file:

  <setting name="emailAddError" value="You must specify an email to add this contact." />

Generate the reference locale file

To generate/update the reference locale file, you must :

  1. in Mail2Voice root folder, open Git Bash : right click > Git Bash,
  2. type: utils/generate_locale_file.sh
  3. check for the default.lng file in the locales folder.
  4. replace the english.lng file with the default.lng file,

Update translations

  1. make sure you have generated the latest reference locale file.
  2. merge changes between the new english.lng and the other locales files and translate the new strings.
translate_mail2voice.txt · Last modified: 2016/02/10 17:41 (external edit)