You may wish to look at an existing translation file to follow along with as an example.
-
Create a file named
TranslationXX.cs
in theLib
folder, whereXX
is the relevant language code, and import theSystem.Collections.Generic
namespace (it will be needed later). Create a new class calledTranslation_xx
, inheriting fromTranslation
, in theSouvenir
namespace:using System.Collections.Generic; namespace Souvenir { public class Translation_xx : Translation { } }
-
Implement the
FormatModuleName
andOrdinal
methods:public abstract string Ordinal(int number); public abstract string FormatModuleName(string moduleNameWithoutThe, string moduleNameWithThe, bool addSolveCount, int numSolved);
Ordinal
should return the ordinal form of any number, e.g. "first", "second", "400th", "-40th".FormatModuleName
should return the module name (formatted with "The") ifaddSolveCount
is false. Otherwise, it should includenumSolved
, e.g. "the Mad Memory that you solved 4th". Use the aforementionedOrdinal
method.
-
Implement the
IntroTexts
property:public abstract string[] IntroTexts { get; }
- Return an array which contains the possible texts to be shown on the module at the start of the bomb before the lights turn on.
-
In the
Translation
class, add an entry to theAllTranslations
dictionary corresponding to the new language.
-
If the
Translations
property has not been overriden, do so now:protected override Dictionary<Question, TranslationInfo> _translations => new()
-
For each question, add an entry to
Translations
with the question itself as the key, and aTranslationInfo
object as the value. The properties to set in this object are as follows:string QuestionText
— The question itself. Make sure to include the relevant format arguments in the correct order.string ModuleName
— the name of the module without "The".string ModuleNameWithThe
— the name of the module with "The", if applicable. If your language does not have an equivalent for "The", leave this unspecified.Dictionary<string, string> Answers
— keys are all possible answers in English, values are the corresponding translations. You must setTranslateAnswers
totrue
in the question definition if you specify this.Dictionary<string, string> FormatArgs
— keys are all possible extra format arguments in English, values are the corresponding translations. If specified, you must also specifyTranslateFormatArgs
in the question definition to indicate which format arguments should be translated.
Note:
- Answers and format arguments should be translated only if they appear translated on the relevant module or if they refer to something that is not written, for example a colour or position. Otherwise, do not specify the relevant dictionaries.
- Ordinals in format arguments, if using the
ordinal
method or theQandA.Ordinal
placeholder, do not need to be translated as theTranslation.Ordinal
method you implemented earlier will handle this.
You can change the module language in the TestHarness with the !1 lang xx
command. Navigate to a module with !1 module name
.
You will find "Souvenir-settings.txt" in the mod-settings folder. In the "Language": field at the bottom, enter the language code (e.g. "Language": "ja"). Note that this item can't be changed from the ModSelector by default; Open the file in Notepad or some IDE.