Supported formats

Weblate supports any translation format understood by Translate-toolkit, however each format being slightly different, there might be some issues with formats that are not well tested.

Note

When choosing a file format for your application, it’s better to stick some well established format in the toolkit/platform you use. This way your translators can use whatever tools they are get used to and will more likely contribute to your project.

Weblate does support both monolingual and bilingual formats. Bilingual formats store two languages in single file - source and translation (typical examples are GNU Gettext, XLIFF or Apple OS X strings). On the other side, monolingual formats identify the string by ID and each language file contains only mapping of those to given language (typically Android string resources). Some file formats are used in both variants, see detailed description below.

For correct use of monolingual files, Weblate requires access to a file containing complete list of strings to translate with their source - this file is called Monolingual base language file within Weblate, though the naming might vary in your application.

Automatic detection

Weblate can automatically detect several widely spread file formats, but this detection can harm your performance and will limit features specific to given file format (for example automatic adding of new translations).

GNU Gettext

Most widely used format in translating free software. This was first format supported by Weblate and still has the best support.

Weblate supports contextual information stored in the file, adjusting its headers or linking to corresponding source files.

The bilingual gettext PO file typically looks like:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Monday"
msgstr "Pondělí"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "Tuesday"
msgstr "Úterý"

#: weblate/accounts/avatar.py:163
msgctxt "No known user"
msgid "None"
msgstr "Žádný"

Monolingual Gettext

Some projects decide to use Gettext as monolingual formats - they code just IDs in their source code and the string needs to be translated to all languages, including English. Weblate does support this, though you have to choose explicitly this file format when importing components into Weblate.

The monolingual gettext PO file typically looks like:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Pondělí"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Úterý"

#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "Žádný"

While the base language file will be:

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-monday"
msgstr "Monday"

#: weblate/media/js/bootstrap-datepicker.js:1421
msgid "day-tuesday"
msgstr "Tuesday"

#: weblate/accounts/avatar.py:163
msgid "none-user"
msgstr "None"

XLIFF

XML-based format created to standardize translation files, but in the end it is one of many standards in this area.

XLIFF is usually used as bilingual, but Weblate supports it as monolingual as well.

Translations marked for review

Changed in version 2.18: Since version 2.18 Weblate differentiates approved and fuzzy states, so it should work as expected with Xliff. You still might apply note below in cases where you don’t want to use review process in Weblate.

If the translation unit doesn’t have approved="yes" it will be imported into Weblate as needing review (which matches XLIFF specification).

You can override this by adding skip-review-flag flag to the component, see Component configuration, which will make Weblate ignore this and all strings will appear as approved.

Similarly on importing such files, you should choose Import as translated under Processing of strings needing review.

Whitespace and newlines in XLIFF

Generally the XML formats do not differentiate between types or ammounts of whitespace. If you want to keep it, you have to add the xml:space="preserve" flag to the unit.

For example:

    <trans-unit id="10" approved="yes">
        <source xml:space="preserve">hello</source>
        <target xml:space="preserve">Hello, world!
</target>
    </trans-unit>

Java properties

Native Java format for translations.

Java properties are usually used as monolingual.

Weblate supports ISO-8859-1, UTF-8 and UTF-16 variants of this format.

Joomla translations

New in version 2.12.

Native Joomla format for translations.

Joomla translations are usually used as monolingual.

Note

You need translate-toolkit 2.1.0 or newer for Joomla support.

Qt Linguist .ts

Translation format used in Qt based applications.

Qt Linguist files are used as both bilingual and monolingual.

Android string resources

Android specific file format for translating applications.

Android string resources are monolingual, the Monolingual base language file file is stored in a different location from the others res/values/strings.xml.

Note

Android string-array structures are not currently supported. To work around this, you can break you string arrays apart:

<string-array name="several_strings">
    <item>First string</item>
    <item>Second string</item>
</string-array>

become:

<string-array name="several_strings">
    <item>@string/several_strings_0</item>
    <item>@string/several_strings_1</item>
</string-array>
<string name="several_strings_0">First string</string>
<string name="several_strings_1">Second string</string>

The string-array that points to the string elements should be stored in a different file, and not localized.

This script may help pre-process your existing strings.xml files and translations: https://gist.github.com/paour/11291062

Apple OS X strings

Apple specific file format for translating applications, used for both OS X and iPhone/iPad application translations.

Apple OS X strings are usually used as bilingual.

Note

You need translate-toolkit 1.12.0 or newer for proper support of Apple OS X strings. Older versions might produce corrupted files.

PHP strings

PHP translations are usually monolingual, so it is recommended to specify base file with English strings.

Example file:

<?php
$LANG['foo'] = 'bar';
$LANG['foo1'] = 'foo bar';
$LANG['foo2'] = 'foo bar baz';
$LANG['foo3'] = 'foo bar baz bag';

Note

Translate-toolkit currently has some limitations in processing PHP files, so please double check that your files won’t get corrupted before using Weblate in production setup.

Following things are known to be broken:

  • Adding new units to translation, every translation has to contain all strings (even if empty).
  • Handling of special chars like newlines.

See also

PHP

JSON and nested structure JSON files

New in version 2.0.

Changed in version 2.16: Since Weblate 2.16 and with translate-toolkit at least 2.2.4 nested structure JSON files are supported as well.

Changed in version 2.17: Since Weblate 2.17 and with translate-toolkit at least 2.2.5 i18next JSON files with plurals are supported as well.

JSON format is used mostly for translating applications implemented in Javascript.

JSON translations are usually monolingual, so it is recommended to specify base file with English strings.

Example file:

{
    "Hello, world!\n": "Ahoj světe!\n",
    "Orangutan has %d banana.\n": "",
    "Try Weblate at https://demo.weblate.org/!\n": "",
    "Thank you for using Weblate.": ""
}

Nested files are supported as well (see above for requirements), such file can look like:

{
    "weblate": {
        "hello": "Ahoj světe!\n",
        "orangutan": "",
        "try": "",
        "thanks": ""
    }
}

See also

JSON

WebExtension JSON

New in version 2.16: This is supported since Weblate 2.16 and with translate-toolkit at least 2.2.4.

File format used when translating extensions for Google Chrome or Mozilla Firefox.

Example file:

{
    "hello": {
        "message": "Ahoj světe!\n",
        "description": "Description"
    },
    "orangutan": {
        "message": "",
        "description": "Description"
    },
    "try": {
        "message": "",
        "description": "Description"
    },
    "thanks": {
        "message": "",
        "description": "Description"
    }
}

.Net Resource files

New in version 2.3.

.Net Resource (.resx) file is a monolingual XML file format used in Microsoft .Net Applications.

Note

You need translate-toolkit 1.13.0 or newer to include support for this format.

CSV files

New in version 2.4.

CSV files can contain a simple list of source and translation. Weblate supports the following files:

  • Files with header defining fields (source, translation, location, ...)
  • Files with two fields - source and translation (in this order), choose Simple CSV file as file format
  • Files with fields as defined by translate-toolkit: location, source, target, id, fuzzy, context, translator_comments, developer_comments

Example file:

Thank you for using Weblate.,Děkujeme za použití Weblate.

See also

CSV

YAML files

New in version 2.9.

There are several variants of using YAML as a translation format. Weblate currently supports following:

  • Plain YAML files with string keys and values
  • Ruby i18n YAML files with language as root node

Note

You currently need a patched version of translate-toolkit to support YAML. Check translate-toolkit issue tracker for more details.

Example YAML file:

weblate:
  hello: ""
  orangutan": ""
  try": ""
  thanks": ""

Example Ruby i18n YAML file:

cs:
  weblate:
    hello: ""
    orangutan: ""
    try: ""
    thanks: ""

See also

YAML

DTD files

New in version 2.18.

Example DTD file:

<!ENTITY hello "">
<!ENTITY orangutan "">
<!ENTITY try "">
<!ENTITY thanks "">

Others

As already mentioned, all Translate-toolkit formats are supported, but they did not (yet) receive deeper testing.

Adding new translations

Changed in version 2.18: In versions prior to 2.18 the behaviour of adding new translations was file format specific.

Weblate can automatically start new translation for all of the the file formats.

Some formats expect to start with empty file and only translated strings to be included (eg. Android string resources), while others expect to have all keys present (eg. GNU Gettext). In some situations this really doesn’t depend on the format, but rather on framework you use to handle the translation (eg. with JSON and nested structure JSON files).

When you specify Base file for new translations in Component configuration, Weblate will use this file to start new translations. Any exiting translations will be removed from the file when doing so.

When Base file for new translations is empty and file format supports it, empty file is created where new units will be added once they are translated.