mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-05-05 07:23:30 +08:00
184 lines
5.8 KiB
ReStructuredText
184 lines
5.8 KiB
ReStructuredText
.. _formats:
|
|
|
|
Supported formats
|
|
=================
|
|
|
|
Weblate supports any format understood by Translate-toolkit, however each
|
|
format being slightly different, there might be some issues with not well
|
|
tested formats.
|
|
|
|
.. seealso:: `Supported formats in translate-toolkit`_
|
|
|
|
|
|
Weblate does support both :index:`monolingual <pair: translation; monolingual>`
|
|
and :index:`bilingual <pair: translation; bilingual>` formats. Bilingual
|
|
formats store two languages in single file - source and translation (typical
|
|
examples is :ref:`gettext`, :ref:`xliff` or :ref:`apple`). On the other side,
|
|
monolingual formats identify the string by ID and each language file contains
|
|
only mapping of those to given language (typically :ref:`aresource`). Some file
|
|
formats are used in both variants, see detailed description below.
|
|
|
|
For correct use of monolingual files, Weblate requires access to file
|
|
containing complete list of strings to translate with their source - this file
|
|
is called :guilabel:`Monolingual base language file` within Weblate, though the
|
|
naming might vary in your application.
|
|
|
|
.. _gettext:
|
|
|
|
GNU Gettext
|
|
-----------
|
|
|
|
.. index:: single: Gettext; Gettext po
|
|
|
|
Most widely used format in translating free software. This was first format
|
|
supported by Weblate and still has best support.
|
|
|
|
Weblate supports contextual information stored in the file, adjusting it's
|
|
headers or linking to corresponding source files.
|
|
|
|
.. seealso:: https://en.wikipedia.org/wiki/Gettext, http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/po.html
|
|
|
|
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 resources into Weblate.
|
|
|
|
.. _xliff:
|
|
|
|
XLIFF
|
|
-----
|
|
|
|
.. index:: single: XLIFF; file format
|
|
|
|
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.
|
|
|
|
.. seealso:: https://en.wikipedia.org/wiki/XLIFF, http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/xliff.html
|
|
|
|
Java properties
|
|
---------------
|
|
|
|
.. index:: single: Java; properties
|
|
|
|
Native Java format for translations.
|
|
|
|
Java properties are usually used as bilingual.
|
|
|
|
.. seealso:: https://en.wikipedia.org/wiki/.properties, http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/properties.html
|
|
|
|
Qt Linguist .ts
|
|
---------------
|
|
|
|
.. index:: single: Qt; file format
|
|
|
|
Translation format used in Qt based applications.
|
|
|
|
Qt Linguist files are used as both bilingual and monolingual.
|
|
|
|
.. seealso:: http://qt-project.org/doc/qt-4.8/linguist-manual.html, http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/ts.html
|
|
|
|
.. _aresource:
|
|
|
|
Android string resources
|
|
------------------------
|
|
|
|
.. index:: single: Android; string resources
|
|
|
|
Android specific file format for translating applications.
|
|
|
|
Android string resources are monolingual, the
|
|
:guilabel:`Monolingual base language file` file being stored in different
|
|
location than others :file:`res/values/strings.xml`.
|
|
|
|
.. seealso:: https://developer.android.com/guide/topics/resources/string-resource.html
|
|
|
|
.. note::
|
|
|
|
This format is not yet supported by Translate-toolkit (merge request is
|
|
pending), but Weblate includes own support for it.
|
|
|
|
.. note::
|
|
|
|
Android `string-array` structures are not currently supported. To work around this,
|
|
you can break you string arrays apart:
|
|
|
|
.. code-block:: xml
|
|
|
|
<string-array name="several_strings">
|
|
<item>First string</item>
|
|
<item>Second string</item>
|
|
</string-array>
|
|
|
|
become:
|
|
|
|
.. code-block:: xml
|
|
|
|
<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:
|
|
|
|
Apple OS X strings
|
|
------------------
|
|
|
|
.. index:: single: Apple; strings
|
|
|
|
Apple specific file format for translating applications, used for both OS X
|
|
and :index:`iPhone <pair: iPhone; translation>`/:index:`iPad <pair: iPad; translation>` application translations.
|
|
|
|
Apple OS X strings are usually used as bilingual.
|
|
|
|
.. seealso:: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/StringsFiles.html, http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/strings.html
|
|
|
|
.. note::
|
|
|
|
Apple OS X strings are half broken in translate-toolkit 1.9.0 (it will
|
|
generate corrupted files while saving), please use Git snapshot for
|
|
handling these.
|
|
|
|
PHP files
|
|
---------
|
|
|
|
.. index:: single: PHP; files
|
|
|
|
PHP files can be processed directly, though currently Translate-toolkit has
|
|
some problems writing them properly, so please double check that your files
|
|
won't get corrupted.
|
|
|
|
PHP translations are usually monolingual, so it is recommended to specify base
|
|
file with English strings.
|
|
|
|
Sample file which should work:
|
|
|
|
.. code-block:: php
|
|
|
|
<?php
|
|
|
|
$string['foo'] = 'This is foo string';
|
|
|
|
.. seealso:: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/php.html
|
|
|
|
|
|
Others
|
|
------
|
|
|
|
As already mentioned, all Translate-toolkit formats are supported, but they
|
|
did not (yet) receive deeper testing.
|
|
|
|
.. seealso:: `Supported formats in translate-toolkit`_
|
|
|
|
.. _Supported formats in translate-toolkit: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/index.html
|