Development tips - gtrxAC/discord-j2me GitHub Wiki
Adding new languages
- Go to
language
folder and create a copy ofen.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).
- Name the new file
- 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.
- Edit
res/icons.png
.- Add a flag icon for the new language.
- Edit
src/com/gtrxac/discord/Icons.java
.- Add a new
Image
field for the flag. Name itflagXX
where XX is the new flag's country code in uppercase. - In the
Icons
constructor, add a new line likeflagXX = next();
. Uses ofnext()
should be in the correct order based on the order of the icons in theicons.png
file, going from left to right, top to bottom.
- Add a new
- 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.
- Add the new language's ID to the
- 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 thelangIds
in step 5. - Add the new language's flag to the
flags
array (likes.ic.flagXX
, whereflagXX
is the name of the field you created in step 4, or one of the existing fields inIcons.java
). The flags should be in the same order as thelangIds
andlangNames
.
- Add the new language's name to the
- 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 (likeTRANSLATOR_XX
), and add the English name for that language to each language's JSONC file (these can later be translated to the respective languages).
- For this, you may want to create a new string ID in
- Compile using
build.sh
orbuild.bat
. - If you're hosting a proxy server, copy the generated language JSON (not JSONC) files from
proxy/static/lang
to your server'sproxy/static/lang
folder.