サポートするフォーマット¶
Wblateはtranslate-toolkitで扱うことのできる翻訳フォーマットのほどんどをサポートしています。しかし個々のフォーマットは少しずつ異なっているため、テストが十分でないフォーマットでは、何らかの問題があるかもしれません。
注釈
アプリケーションのファイルフォーマットを選ぶ際には、使用するツールキットやプラットフォームで十分に実績のあるフォーマットにしたほうがよいでしょう。これにより翻訳者は使いたいどんなツールでも使うことができますので、よりプロジェクトへの貢献が期待できます。
複式言語フォーマットと単一言語フォーマット¶
Weblate は 単一言語 と 複式言語 の双方のフォーマットをサポートしています。複式言語フォーマットはひとつのファイルに、原文と翻訳という、ふたつの言語を収めます。典型的な例としては GNU Gettext や XLIFF や Apple OS X strings などがこれに当たります。一方の単一言語フォーマットは、原文の文字列をIDで識別し、それぞれ個別の言語ファイルに ID とそれに対応する翻訳文字列を収めます。 典型的には Android string resources がこれに当たります。ファイルフォーマットによってはこの両方で使われることもあります。詳しくは以下の説明を参照してください。
単一言語ファイルを正しく扱うためには、Weblate は翻訳すべき文字列とそのソースの完全なリストを持つファイルに、アクセスできる必要があります。このファイルを Weblate では 単一基盤言語ファイル と呼んでいますが、アプリケーションによって呼び方は違うかもしれません。
自動検出¶
広く普及している幾つかのファイルフォーマットに関しては、Weblate は自動で検出することができます。しかしこの検出はパフォーマンスを低下させ、そのファイルフォーマット固有の機能を制限する可能性があります(例えば新規翻訳の自動追加など)。
可能な翻訳のタイプ¶
以下は可能な翻訳タイプを、サポートするすべてのフォーマットで一覧にしたものです。
フォーマット | 言語 | 注釈 | 文脈 | 場所 | Additional states [1] |
---|---|---|---|---|---|
GNU Gettext | 複式 | はい | はい | はい | needs editing |
単一言語 Gettext | 単一 | はい | はい | はい | needs editing |
XLIFF | 両方 | はい | はい | はい | needs editing, approved |
Java properties | 単一 | はい | いいえ | いいえ | |
Joomla translations | 単一 | はい | いいえ | はい | |
Qt Linguist .ts | 両方 | はい | いいえ | はい | needs editing |
Android string resources | 単一 | はい | いいえ | いいえ | |
Apple OS X strings | 複式 | はい | いいえ | ||
PHP strings | 単一 | はい | いいえ | いいえ | |
JSON files | 単一 | いいえ | いいえ | いいえ | |
WebExtension JSON | 単一 | はい | いいえ | いいえ | |
.Net Resource files | 単一 | はい | いいえ | いいえ | |
CSV files | 単一 | はい | はい | はい | needs editing |
YAML files | 単一 | はい | いいえ | いいえ | |
DTD files | 単一 | いいえ | いいえ | いいえ | |
Windows RC files | 単一 | いいえ | いいえ | ||
Excel Open XML | 単一 | はい | はい | はい | needs editing |
[1] | Additional states supported by the file format in addition to not translated and translated. |
GNU Gettext¶
フリーソフトウェアの翻訳において最も広く使われている形式です。これは Weblate において最初にサポートされたフォーマットであり、現在においても最も手厚くサポートされています。
Weblate はファイルに格納された文脈情報をサポートしています。これによりヘッダを調整したり、対応するソースファイルへリンクしたりします。
複式言語形式の gettext PO ファイルは典型的には次のようなものです。
#: 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ý"
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | po/*.po |
単一言語基盤言語ファイル | 空 |
新規翻訳のためのベースファイル | po/messages.pot |
ファイルフォーマット | Gettext PO ファイル |
参考
Gettext on Wikipedia, PO Files, Update ALL_LINGUAS variable in the configure file, Customize gettext output, Update LINGUAS file, Generate MO files, Update PO files to match POT (msgmerge),
単一言語 Gettext¶
プロジェクトによっては Gettext を単一言語形式で使用すると決定することがあります。ソースコードには ID のみをコーディングし、文字列は英語を含むすべての言語に訳さねばなりません。Weblate はこの形式もサポートしていますが、コンポーネントをインポートする際に明示的にこのファイルフォーマットを選択せねばなりません。
単一言語 gettext PO ファイルは典型的には次のようなものです。
#: 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ý"
一方、基盤言語ファイルは次のようになります。
#: 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"
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | po/*.po |
単一言語基盤言語ファイル | po/en.po |
新規翻訳のためのベースファイル | po/messages.pot |
ファイルフォーマット | Gettext PO file (単一言語) |
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 states¶
The state
attribute in the file is partially processed and mapped to needs
edit state in Weblate (the following states are used to flag the string as
needing edit if there is some target present: new
, needs-translation
,
needs-adaptation
, needs-l10n
). Should the state
attribute be
missing a unit is considered translated as soon as a <target>
element
exists.
Also if the translation unit has approved="yes"
it will be imported into Weblate
as approved, anything else will be imported as waiting for review (which matches XLIFF
specification).
That means that when using XLIFF format, it is strongly recommended to enable Weblate review process, in order to see and change the approved state of units. See Dedicated reviewers.
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 amounts 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>
Typical Weblate コンポーネント設定 for bilingual XLIFF | |
---|---|
ファイルマスク | localizations/*.xliff |
単一言語基盤言語ファイル | 空 |
新規翻訳のためのベースファイル | localizations/en-US.xliff |
ファイルフォーマット | XLIFF Translation File |
Typical Weblate コンポーネント設定 for monolingual XLIFF | |
---|---|
ファイルマスク | localizations/*.xliff |
単一言語基盤言語ファイル | localizations/en-US.xliff |
新規翻訳のためのベースファイル | localizations/en-US.xliff |
ファイルフォーマット | XLIFF Translation File |
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. All of
them supports storing all Unicode characters, it's just differently encoded. In
the ISO-8859-1 the Unicode escape sequences are used (eg. zkou\u0161ka
),
all others encode characters directly either in UTF-8 or UTF-16.
注釈
Loading of escape sequences will work in UTF-8 mode as well, so please be careful choosing correct charset matching your application needs.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | src/app/Bundle_*.properties |
単一言語基盤言語ファイル | src/app/Bundle.properties |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | Java Properties (ISO-8859-1) |
Joomla translations¶
バージョン 2.12 で追加.
Native Joomla format for translations.
Joomla translations are usually used as monolingual.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | language/*/com_foobar.ini |
単一言語基盤言語ファイル | language/en-GB/com_foobar.ini |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | Joomla Language File |
Qt Linguist .ts¶
Translation format used in Qt based applications.
Qt Linguist files are used as both bilingual and monolingual.
Typical Weblate コンポーネント設定 when using as bilingual | |
---|---|
ファイルマスク | i18n/app.*.ts |
単一言語基盤言語ファイル | 空 |
新規翻訳のためのベースファイル | i18n/app.de.ts |
ファイルフォーマット | Qt Linguist Translation File |
Typical Weblate コンポーネント設定 when using as monolingual | |
---|---|
ファイルマスク | i18n/app.*.ts |
単一言語基盤言語ファイル | i18n/app.en.ts |
新規翻訳のためのベースファイル | i18n/app.en.ts |
ファイルフォーマット | Qt Linguist Translation File |
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
.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | res/values-*/strings.xml |
単一言語基盤言語ファイル | res/values/strings.xml |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | Android String Resource |
注釈
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.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | Resources/*.lproj/Localizable.strings |
単一言語基盤言語ファイル | Resources/en.lproj/Localizable.strings |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | OS X Strings (UTF-8) |
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';
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | lang/*/texts.php |
単一言語基盤言語ファイル | lang/en/texts.php |
新規翻訳のためのベースファイル | lang/en/texts.php |
ファイルフォーマット | PHP strings |
注釈
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.
参考
JSON files¶
バージョン 2.0 で追加.
バージョン 2.16 で変更: Since Weblate 2.16 and with translate-toolkit at least 2.2.4 nested structure JSON files are supported as well.
バージョン 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.
Weblate currently supports several variants of JSON translations:
- Simple key / value files.
- Files with nested keys.
- The i18next files with support for plurals.
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": ""
}
}
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | langs/translation-*.json |
単一言語基盤言語ファイル | langs/translation-en.json |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | JSON nested structure file |
WebExtension JSON¶
バージョン 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"
}
}
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | _locales/*/messages.json |
単一言語基盤言語ファイル | _locales/en/messages.json |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | WebExtension JSON file |
.Net Resource files¶
バージョン 2.3 で追加.
.Net Resource (.resx) file is a monolingual XML file format used in Microsoft .Net Applications. It works with .resw files as well as they use identical syntax to .resx.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | Resources/Language.*.resx |
単一言語基盤言語ファイル | Resources/Language.resx |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | .Net resource file |
CSV files¶
バージョン 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.
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | locale/*.csv |
単一言語基盤言語ファイル | 空 |
新規翻訳のためのベースファイル | locale/en.csv |
ファイルフォーマット | CSV file |
参考
YAML files¶
バージョン 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
Example YAML file:
weblate:
hello: ""
orangutan": ""
try": ""
thanks": ""
Example Ruby i18n YAML file:
cs:
weblate:
hello: ""
orangutan: ""
try: ""
thanks: ""
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | translations/messages.*.yml |
単一言語基盤言語ファイル | translations/messages.en.yml |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | YAML file |
参考
DTD files¶
バージョン 2.18 で追加.
Example DTD file:
<!ENTITY hello "">
<!ENTITY orangutan "">
<!ENTITY try "">
<!ENTITY thanks "">
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | locale/*.dtd |
単一言語基盤言語ファイル | locale/en.dtd |
新規翻訳のためのベースファイル | 空 |
ファイルフォーマット | DTD file |
Windows RC files¶
バージョン 3.0 で追加: Experimental support has been added in Weblate 3.0, not supported on Python 3.
Example Windows RC file:
LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE
BEGIN
IDS_MSG1 "Hello, world!\n"
IDS_MSG2 "Orangutan has %d banana.\n"
IDS_MSG3 "Try Weblate at http://demo.weblate.org/!\n"
IDS_MSG4 "Thank you for using Weblate."
END
典型的な Weblate コンポーネント設定 | |
---|---|
ファイルマスク | lang/*.rc |
単一言語基盤言語ファイル | lang/en-US.rc |
新規翻訳のためのベースファイル | lang/en-US.rc |
ファイルフォーマット | RC file |
Excel Open XML¶
バージョン 3.2 で追加.
Weblate can import and export Excel Open XML (xlsx) files.
When using xlsx files for translation upload, be aware that only the active
worksheet is considered and there must be at least a column called source
(which contains the source string) and a column called target
(which
contains the translation). Additionally there should be the column context
(which contains the context path of the translation unit). If you use the xlsx
download for exporting the translations into an Excel workbook, you already get
a file with the correct file format.
Others¶
Most formats supported by translate-toolkit which support serializing can be easily supported, but they did not (yet) receive any testing. In most cases some thin layer is needed in Weblate to hide differences in behavior of different translate-toolkit storages.
Adding new translations¶
バージョン 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 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 files).
When you specify Base file for new translations in コンポーネント設定, 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.