Make text translatable

  1. In HTML or PHP wrap it like this <?php echo $l->t('This is some text');?>
  2. For the right date format use <?php echo $l->l('date', time());?>.  Change the way dates are shown by editing /core/l10n/l10n-[lang].php
  3. To translate text in javascript use:  t('appname','text to translate');

You shall never split sentences!


Translators loose the context and they have no chance to possible re-arrange words.


<?php echo $l->t('Select file from') . ' '; ?><a href='#' id="browselink"><?php echo $l->t('local filesystem');?></a><?php echo $l->t(' or '); ?><a href='#' id="cloudlink"><?php echo $l->t('cloud');?></a>

Translators will translate:

  • Select file from
  • local filesystem
  • ‘ or ‘
  • cloud
By translating these individual strings for sure the case will be lost of “local filesystem” and “cloud”. The two white spaces with the or will get lost while translating as well.

Html on translation string:

Html tags in translation strings is ugly but usually translators can handle this.

What about variable in the strings?

In case you need to add variables to the translation strings do it like that:
 $l->t('%s is available. Get <a href="%s">more information</a>',array($data['versionstring'], $data['web']));

Automated synchronization of translations

Multiple nightly jobs have been setup in order to synchronize translations – it’s a multi-step process:
  1. ‘perl read’ will rescan all php and javascript files and generate the templates.
  2. The templates are pushed to Transifex (tx push -s).
  3. All translations are pulled from Transifex (tx pull -a).
  4. ‘perl write’ will write the php files containing the translations.
  5. Finally the changes are pushed to git.

Please follow the steps below to add translation support to your app:

  1. Create a folder ‘l10n’.
  2. Create the file ‘ignorelist’ which can contain files which shall not be scanned during step 4.
  3. Edit ‘l10n/.tx/config’ and copy/past a config section and adopt it by changing the app/folder name.
  4. Run ‘perl read’ with l10n
  5. Add the newly created translation template (l10n/Templates/<appname>.pot) to git and commit the changes above.
After the next nightly sync job a new resource will appear on Transifex and from now on every night the latest translations will arrive.

Translation sync jobs:


Caution: information below is in general not needed !

Manual quick translation update:

cd l10n/ && perl read && tx push -s && tx pull -a && perl write && cd ..
The translation script requires Locale::PO, installable via apt-get install liblocale-po-perl

Configure transifex

tx init
for resource in calendar contacts core files media gallery settings
tx set --auto-local -r owncloud.$resource "<lang>/$resource.po" --source-language=en \
 --source-file "templates/$resource.pot" --execute