Skip to content

Creating a new translation

Andrei Kurosh edited this page Apr 22, 2024 · 1 revision

To add a translation to a new language in Bonsai, the following should be done:

  1. Add a new ResX file with localized strings next to src/Bonsai/Localization/Texts.resx similarly to the existing ones.

  2. Translate all strings from the Texts.en-US.resx file.

    If a string contains a placeholder, like {0}, it should be left intact. The values to be inserted into those places are described in the comment.

    If a string contains a vertical line separator (|), they should also be left intact. There should be no spaces around the separator.

    If the key ends with M or F suffix, these mean male and female context respectively. In some lines the English form will be the same, but it can be different for other languages.

  3. Add a new class deriving from LocaleBase in src/Bonsai/Code/Services/LocaleProvider.cs. It should contain a function to resolve the appropriate word form depending on the quantity (e.g. "1 son, 2 sons").

    The instance of this class should be registered in the LocaleProvider.Locales field in the same class.

  4. Add Guidelines.<locale>.cshtml and Markdown.<locale>.cshtml to /src/Bonsai/Areas/Admin/Views/Help. Translate their contents.

  5. Add translations for month and day names to src/Bonsai/Areas/Common/Libs/gijgo.core.js similarly to existing ones.

  6. Add README.<locale>.md to the root folder, translate its contents.

  7. Mention the newly created locale in other README files.