-
-
Notifications
You must be signed in to change notification settings - Fork 5
HowTo: Create Language Strings
A translation file contains three major parts: comments (indicated by a # at the beginning of a line), identifiers (usually in uppercase letters and at the beginning of a line) and the actual language strings (after the identifiers and an additional =, probably containing some place holders %%1%% or %%COMMON_YES_NO%%). Leading or trailing whitespaces/tabulator characters in the language strings or whitespaces between an identifier and the equal sign will be ignored:
#This is a comment
THIS_IS_AN_IDENTIFIER=This is the actual language string and a %%PLACE_HOLDER%%
- Place holders containing only numbers will be replaced during the execution of NumeRe and with the relevant message part.
- The others will be replaced during language loading (at start up) with the language strings of the referenced identifiers, if they can be found.
NumeRe contains three major language files: <>/lang/main.nlng, <>/lang/numere.nlng and <>/lang/error.nlng. The first contains all the language strings for usual interaction, the second specific strings for syntax elements, whereas the last contains all error messages. There are further files prefixed with tmpl_*.nlng. These contain templates for scripts, plugins and files. Note, that the comments in these files will be copied to the generated file.
You can create your own language string identifiers in your code contribution, if you use the Language class to access its value from the language files. It is not necessary to know the explicit file, the class will take care about that. For the GUI part of the application you can access the language string via the global _guilang instance, within the kernel part stick to _lang instead. Just search for occurences of one of those two instances to understand how to use them.
Some code contributions require implicitly that you add language strings to those language files. Those are especially, if you contribute by implementing your own function or command. Here, you will have to make multiple changes:
- add the function or command names (as well as possible options) to
./common/syntaxelements.nlng - add the necessary tooltips to
./en-GB/lang/numere.nlng(and thede-DEfolder as well) as-
PARSERFUNCS_LISTFUNC_FUNC_name in uppercase_[category in uppercase]for functions -
PARSERFUNCS_LISTCMD_CMD_name in uppercase_[category in uppercase]for commands
-
- add the search strings to the database in
./en-GB/docs/find.ndb(and thede-DEfolder as well). You can use the NDB Browser for editing those files, which you may download through the built-in package manager. This will make it much simpler to edit those files correctly.
Keep in mind that we only accept language strings, if they appear in every language. If you have troubles with the other available languages, please get in touch for support.
Writing a translation is quite easy. All you have to do, is to translate every language string you're finding in the language files to your desired language. Please keep in mind that NumeRe is currently not capable of displaying Unicode, so stick to the standard ASCII alphabet.
The special dollar sign $ represents a line break in the language string. If you want to use the dollar sign as a literal character, you have to escape it with a backslash: \$
You may add your own identifiers, if you like to. But these identifiers can only be used to replace place holders in other language strings during loading time. For example, you could do something like
LANG_STRING=language string
THIS_IS_AN_IDENTIFIER=This is the actual %%LANG_STRING%% and a %%PLACE_HOLDER%%
to obtain the upper example. But, we'd like to beg you that you prefix your own identifier with USER_* that they won't interfere with our standard identifiers.