Development tips - gtrxAC/discord-j2me GitHub Wiki

Adding new languages

  1. Go to language folder and create a copy of en.jsonc.
    • Name the new file xx.jsonc where xx is the language's two-digit code.
    • If this is a regional variant (and not the most commonly used regional variant) of a language, name it xx-XX.jsonc, where xx is the language's code (lowercase) and XX is the country code (uppercase).
  2. Edit the new JSONC file.
    • JSONC (JSON with Comments) is best edited with Visual Studio Code, which natively supports this format and warns about any syntax errors.
    • Translate each string into the target language. In most cases, all whitespace, punctuation, and control characters (e.g. \n for line break) should stay the same.

If you are not a developer, you can now create a pull request to add the new language. If you know basic Java programming and are willing to do the work, keep going and read below.

If your language requires a new flag icon, do steps 3 and 4. If res/icons.png already contains a suitable flag, skip those steps.

  1. Edit res/icons.png.
    • Add a flag icon for the new language.
  2. Edit src/com/gtrxac/discord/Icons.java.
    • Add a new Image field for the flag. Name it flagXX where XX is the new flag's country code in uppercase.
    • In the Icons constructor, add a new line like flagXX = next();. Uses of next() should be in the correct order based on the order of the icons in the icons.png file, going from left to right, top to bottom.
  3. Edit src/com/gtrxac/discord/Locale.java.
    • Add the new language's ID to the langIds array. The language IDs should be in alphabetical order.
  4. Edit src/com/gtrxac/discord/LanguageSelector.java.
    • Add the new language's name to the langNames array. The language names should be in the same order as the langIds in step 5.
    • Add the new language's flag to the flags array (like s.ic.flagXX, where flagXX is the name of the field you created in step 4, or one of the existing fields in Icons.java). The flags should be in the same order as the langIds and langNames.
  5. Add the translation author's name to AboutForm.java.
    • For this, you may want to create a new string ID in Strings.java for the language's name (like TRANSLATOR_XX), and add the English name for that language to each language's JSONC file (these can later be translated to the respective languages).
  6. Compile using build.sh or build.bat.
  7. If you're hosting a proxy server, copy the generated language JSON (not JSONC) files from proxy/static/lang to your server's proxy/static/lang folder.