🈁Translating LANraragi to other languages
Details on making additional translations for the server's Web UI.
LRR will automatically render its web UI in the language requested by your web browser's Accept-Language
header, if it supports it.
Unsupported languages will fallback to English.
Here are some pointers on contributing additional translations to LANraragi.
LRR uses standard .po
files to contain its localizations.
Translate client-side text (JavaScript messages)
Coming soon! 🏗️
Translate server-side text (HTML templates)
First, open the locales\template
folder where you will see the current translation files.
It's recommended to use the en.po
file as your base for translation.
Next, make a copy of en.po
and rename it to the language you wish to translate into, for example, zh.po
. Then, open the zh.po
file.
There, you will see something like this:
For translation purposes, you need only modify the content in msgstr
. For instance, if you are translating from English to Chinese, you would replace the English in msgstr
with the corresponding Chinese. For example: msgstr "Database Backup/Restore"
becomes msgstr "数据库备份/恢复"
.
Continue translating the text within msgstr
into your language, and that will complete the translation of the text within LANraragi's templates!
Here are a few points you might need to pay attention to:
Some translation texts include HTML styles. It's advisable not to remove these styles; instead, match the styles with your translated text accordingly.
Some translation files contain placeholders. It's crucial not to delete these placeholders. Only translate the content excluding placeholders and then position the placeholders appropriately. For example:
msgstr "Version %1 %2"
should becomemsgstr "版本 %1 %2"
.Due to the limitations of
Locale::Maketext
, some special texts require special handling. Currently, there's one known special case:msgstr "<b>~namespace</b> : strips the namespace from the tags"
Make sure not to discard the~
when you see themsgid
formsgid "namespace : strips the namespace from the tags"
, because~
is recognized as an escape character inLocale::Maketext
(though attempts to use~~
haven't been successfully recognized).
Handling Missing Translations in templates
If you notice that some texts are missing translations in the relevant template
files, here is a step-by-step example of how to address this, using an example with missing translation text found in index.html.tt2
.
For instance, the following code in your template:
To handle the missing translation, wrap the text with [% c.lh("...text to be handled...") %]
like this:
Then, locate # ------Start of Index.html.tt2------
in the en.po
file, which marks where the corresponding text in the template begins. Add the following entries:
Here, msgid
is used to match the text, and msgstr
contains the translated text.
It is crucial to ensure that the text in msgid
is exactly as it appears post-modification in your template to ensure proper matching. For example, the code below includes an extra space, causing a mismatch which prevents it from being replaced correctly:
For special cases, like in config.html.tt2
, which looks like this:
You'll need to use placeholders:
In translation files, placeholders should be written as %number
instead of [_number]
used in templates. Therefore, it should be:
There are also peculiar cases such as the following found in config_tags.html.tt2
:
Here, ~
is a designated escape character in Locale::Maketext
, so including a ~
in msgid
will prevent proper matching. However, including ~
in msgstr
won't affect functionality, thus it's preferable to remember this nuance:
Last updated