This document will describe how to properly tranlate WebCord client to your language (if you feel more comfortable in using it in your native language rather than in English).
Since version 2.0.0
, there were a major change regarding to the localization
files loading method. From this version, errors are properly handled, so the
application no longer crashes when there's some syntax/type error in the
translation files and loads the fallback strings instead.
Other change introduced with this version was that English localization files
were moved to sources/code/modules/l10n.ts
, so their type
Before you will begin to translate WebCord, you should understood a basics about WebCord's localization support implementation.
In the WebCord sources, you may have noticed the following directory:
sources/assets/translations
. This is the folder where official translations
are published and which are always distributed within the application itself.
To get information about the system language, WebCord also uses
app.getLocale()
Electron API, which (as described in Electron Docs) uses the Chromium
l10n_util
library to get information about the system language. Hence the
folder names in translations
folder are possible values returned by
app.getLocale()
function, the list of possible code names is described
here.
As of the translation format, WebCord is capable of understanding the two file formats:
- Regular JSON files.
- JSONC (aka. JSON with Comments) file format.
JSONC parser supports following comment styles:
- C-like end-of-line comments:
// Example of end-of-line comment
- C++-like block comments (both single-line and multi-line):
/* Single-line comment */
/**
* Multi-line comment
*
* Can be used for longer description
*/
/*
* Two 'star' symbols for opening a comment
* isn't a requirement BTW
*/
-
Download and install latest WebCord version.
-
Check which is the code name of the language to which you want to translate WebCord, that is supported by Chromium L10N library. You find list of available language codes in this file.
-
Create a new folder with the name of the target language – the code name you found in previous step.
-
Run
webcord --export-l10n={dir}
, where{dir}
is a directory you've created in previous step. -
Copy reference strings to that folder and translate them, either following JSON standard or JSONC file format if you want comments support. Be aware that comments in regular JSON files (
*.json
) are treated as a syntax error by WebCord. -
If you're done with translating WebCord, you can test your translations by coping the folder that you previously made to
{Path where 'app.asar' is placed}/translations
– on Windows and Linux,app.asar
is usually placed in theresources
folder next to WebCord's Electron binary.