Friendica Directory Localization
The Friendica Directory interface is available in multiple languages.
We are using a gettext-like process to generate and parse translations files, which enables translators to use their usual software to translate strings.
The translations files are located in
- The compiled MO file can be generated from a translation software and will be loaded by default.
- The PO file is the main translation interface and can be loaded if the MO file doesn't exist.
Thanks for your interest in translating the Friendica Directory interface!
Please head over to the Friendica Directory Transifex page where you will need an account to start translating the existing strings. The translations will be included in the next release.
Add a new locale
Adding a new locale requires to edit
src/settings.php to add it to the
The base translation file can then be generated with
bin/console extract-string <locale>.
Translate existing strings
PO files can be edited with translation software like Poedit. Please make sure your software is able to compile MO files to update the existing one.
Both PO and MO files should be committed with Git before being submitted in a GitHub pull request. Please refer to the GitHub flow documentation if you're unfamiliar with it.
Add new translation strings
Once templates/controllers files have been edited with new translation strings, you can run
bin/console extract-strings --all to update the PO files of all available languages at once.
Translation functions usage
$this->__('Label %s', 'test')=>
With context, if a base english term can have multiple meanings:
$this->p__('noun', 'Search %s', 'test')=>
$this->p__('verb', 'Search %s', 'test')=>
$this->p__('Label', 'Labels', 1)=>
$this->p__('Label', 'Labels', 3)=>
$this->p__('%d Label', '%d Labels', 1)=>
$this->p__('%d Label', '%d Labels', 3)=>
$this->p__('%d Label', 'Labels %2%s %3%s', 1, 'test', 'test2')=>
Label test test2
$this->p__('%d Label', 'Labels %2%s %3%s', 3, 'test', 'test2')=>
Labels test test2
You will need to add the
l10n dependency to your class before you can use it (see Pager).
$this->l10n->ngettext('Label', 'Labels', 3)
$this->l10n->npgettext('context', 'Label', 'Labels', 3)