This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
How to language
Elias Schaut edited this page Nov 28, 2021
·
3 revisions
- Create a JSON file in folder lang and name it
text_<lang>.json
- Copy json from another language file and translate it
- Edit lang_paths in config file
Access language manager with one of this options:
await require("../../lang/lang_helper").get_text(message, <key>)
await message.client.lang_helper.get_text(message, <key>)
await client.lang_helper.get_text(message, <key>)
The <key>
stands for the key in a language file.
The function returns the string from the correct language file from the user. If the database has no language information about the user, it will take the default language (which is set in the conifg file).
(The message object must be submitted because its important for choosing the correct language and access important funtions)
If you want to insert something into a text that is not known until runtime, you can do this using special characters used in this project:
- Write
%<index>
in lang-element for the gap on the i-th positions - Call the function
get_text
with the needed inserts, but be careful, the order is important
Lang-File:
"text": "Here is the number %1 and also the number %0"
Method-Call:
await msg.client.lang.get_text(msg, text, 42, 420)
// returns "Here is the number 420 and also the number 42"