CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 71
Translations
Translating Wavelog is a big task and needs continuous contributions from the community. We already have 26 additional languages (March 2025) that are partially translated in addition to our base language, English. To improve the translations and add more languages in the future, we need the help of all users and the international hamradio community.
To make translating Wavelog as easy as possible, we stopped working with the CodeIgniter built-in language engine and switched over to gettext()
and po
files, which brings a huge benefit to our development workflow.
In addition to that, we created a platform based on the open-source software Weblate to help contributors who aren't skilled with raw code. In this wiki, we want to explain how you can translate and make Wavelog accessible to as many nations as possible.
You can't find your language on the translation platform? No problem! Send a mail to translation@wavelog.org and we add your language to Wavelog.
The easiest way to start translating is to use our translation-platform https://translate.wavelog.org. Create an account and start translating your language. You also can edit wrong translations and correct them here. Please keep in mind that some translations are meant to be like that.
Your translations will be automatically included in a Pull Request to our dev
branch after 24 hours.
So you don't have to do anything more then translating. So easy :)
If you are skilled with other software like "Poedit" or you like to just translate directly in the code you can do following.
Create a fork in github and clone your fork repo to your local pc. You now can either download the language file and edit it with software like "Poedit" or edit it manually. The language files are located in
application/locale/[language code]/LC_MESSAGES/messages.po
So for example the german language file is application/locale/de_DE/LC_MESSAGES/messages.po
.
After you edited the file commit the changes to your repo and create a Pull Request agains dev
branch.
Important: Never include the
mo
files into that PR. We will generate mo files directly in the repo automatically after the Pull Request was merged. To test your translations locally you can run the scriptpo_gen.sh
which is placed in the main folder of Wavelog. This will generate the mo file for you. Just push the files you changed manually. Nomo
files or files which where generated by the script.
For developers which want to add new strings in PHP you can use the classic gettext()
function which a slightly different syntax. You need to add an underline _
as prefix as we use a emulated variant of gettext to make it work with codeigniter.
After you added the gettext functions in the PHP code you just need to run the script po_gen.sh
which is placed in the main folder of Wavelog. It will generate all necessary pot/po files. It also will compile the mo files, but remember to not add the mo files into the Pull Request.
./po_gen.sh
We mainly use four different functions to show text in our views.
Hint: The use of double quotes
"
in .po files is problematic as we can't escape them with\
. The compiler from po to mo files fails if there are backslashes in the message string. For this reason I recommend to ALWAYS use double quotes in the functions to avoid syntax errors (e.g.__("Text")
instead__('Text')
)
This is the base function for gettext. It searches for translations and if nothing is found it just displays the content of the string. In our case English as source language.
Example
__("Hello World!") or _gettext("Hello World!")
// Prints out:
"Hello World!"
To get a dynamic language which recognizes singular and plural. This is pretty simple accomplished with the _ngettext()
function. Critical here is the third parameter $integer
which has to be an integer, otherwise it throws an error. To avoid that we can use intval()
in the case that the variable is a string.
Example
_ngettext("Banana", "Bananas", 2);
// Prints out Plural because integer is > 1:
"Bananas"
$apples = '1';
_ngettext("Apple", "Apples", intval($apples));
// Prints out Singular because integer is = 1:
"Apple"
This function provides additional information for translators. In some cases an english word can have more then two meanings in a target language. The other use case is to provide a specific context if the text is may incomplete. In these cases it's good practice to provide additional informations to the translators with the _pgettext()
function. So everytime it is may not clear what is meant in the string just use _pgettext()
to provide some additional information. This helps and doesn't hurt.
Example
_pgettext("Noun; Metal", "lead");
// Prints out:
"lead"
// But the german translator knows to translate it as "Blei"
_pgettext("Verb; Lead someone", "lead");
// Prints out:
"lead"
// But the german translator knows to translate it as "führen"
This is no function of gettext, but we really need this function now. Reason is that we don't want URL's in the translation files or the compiled .mo binarys for security reasons. For build inline text links we can use sprintf()
to place variables and other stuff in the translations. This is common practice and works super easy.
sprintf(__("Click %shere%s to visit the website."), '<a href="https://www.wavelog.org" target="_blank">', '</a>');
Prints out in HTML:
'Click <a href="https://www.wavelog.org" target="_blank">here</a> to visit the website.'
Use %s
for strings and %d
for integers or floats. You can place multiple placeholders in the function aswell. They will be place in the order you define them.
sprintf(__("Link %s, Link %s, Link %s, Number %d, Number %d"), "A", "B", "C", 1, 2);
// Prints out:
"Link A, Link B, Link C, Number 1, Number 2"
- Installation on Linux server
- Installation on Windows server
- Installation via Docker
- Updating Wavelog
- Hints & Tips
- wavelog.php Config
- Migrate Cloudlog to Wavelog
- HTTPS Support
- Authentication
- QSO Modes
- Backup
- Update Country Files
- User Accounts
- Global Options
- Debug
- Maintenance Mode
- Migrate servers
- API
- Station Profiles
- Radio Interface
- ADIF Import / Export
- Logbook of The World
- eQSL
- Print Requested QSLs
- Clublog Upload
- QRZ Logbook
- KML Export