在地化檔案格式

Weblate supports a wide range of translation formats. Each format is slightly different and provides a different set of capabilities.

提示

為您的應用程式選擇檔案格式時,最好在您使用的工具箱/平臺中保留一些公認的格式。這樣,您的翻譯人員可以額外使用他們習慣使用的任何工具,並且更有可能為您的專案做出貢獻。

自動偵測

Weblate tries to detect file format during 新增翻譯專案和組件. The detection might be wrong for different variants of the same serialization format (JSON, YAML, properties) or file encoding, so please verify that 檔案格式 is correct before creating the component.

翻譯類型功能

Please refer to the documentation page of each individual file format for information about which features are supported in that format.

雙語言和單語格式

支援 monolingual 和 bilingual 格式。雙語言格式在單個文件中儲存兩種語言 —— 源和翻譯(典型範例是 GNU gettext PO (Portable Object)XLIFF 1.1 與 1.2蘋果 iOS 字串 字串)。另一方面,單語格式通過 ID 識別字串,每個語言文件僅包含那些語言到任何給定語言(通常是 Android 字串資源)的映射。兩種變體都使用某些檔案格式,請參閱下面的詳細說明。

為了正確使用單語文件,Weblate 要求存取一個包含完整字串清單的文件,以與其來源一起翻譯—— 該文件在Weblate 中稱為 單語的基底語言檔案,儘管命名方式可能會有所不同。

另外,可以利用 中間語言檔案 擴充此工作流程,以包括開發人員提供的字串,但不要在最終的字串中使用。

字串狀態

Many file formats only differentiate "Untranslated" and "Translated" strings. With some formats it is possible to store more fine-grained state information, such as "Needs editing" or "Approved".

來源字串描述

Source string descriptions can be used to pass additional info about the string to translate.

Several formats have native support for providing additional info to translators (for example XLIFF 1.1 與 1.2, GNU gettext PO (Portable Object), WebExtension JSON, CSV 檔案, Excel Open XML, Qt Linguist .ts, go-i18n JSON 檔案, gotext JSON 檔案, ARB 檔案, .NET 資源檔案 (RESX, RESW)). Many other formats extract closest comment as source string description.

解釋

The 解釋 on strings can be stored and parsed from a few file formats.

Currently supported only in TermBase eXchange 格式.

來源字串位置

原始碼中字串的位置會幫助熟練的翻譯者識別出字串如何使用。

This information is typically available in bilingual formats where strings are extracted from the source code using tools. For example GNU gettext PO (Portable Object) and Qt Linguist .ts.

翻譯旗標

Translation flags allow customizing Weblate behavior. Some formats support defining those in the translation file (you can always define them in the Weblate interface, see 使用標誌自訂行為).

This feature is modelled on flags in GNU gettext PO (Portable Object).

Additionally, for all XML based format, the flags are extracted from the non-standard attribute weblate-flags. Additionally max-length:N is supported through the maxwidth attribute as defined in the XLIFF standard, see 指定翻譯旗標.

情境

Context is used to differentiate identical strings in a bilingual format used in different scopes (for example Sun can be used as an abbreviated name of the day "Sunday" or as the name of our closest star).

For monolingual formats the string identifier (often called key) can serve the same purpose and additional context is not necessary.

複數化字串

將帶有不同數量的字串正確在地化時複數是必要的。規則取決於一個目標語言並且許多格式遵循 CLDR 規範。

提示

Pluralizing strings need proper support from the application framework as well. Choose native format of your platform such as GNU gettext PO (Portable Object), Android 字串資源 or Stringsdict 格式.

唯讀字串

將包含來自翻譯文件的唯讀字串,但不能在 Weblate 中編輯。此功能本功能僅由少量格式支援( XLIFF 1.1 與 1.2Android 字串資源),但可以通過新增一個 read-only 標記,參閱 使用標誌自訂行為

支援其他格式

Most formats supported by translate-toolkit which support serializing can be easily supported, but they did not (yet) received any testing. In most cases, an additional thin layer is needed in Weblate to hide differences in behavior of different storages.

要為新格式新增支援,首先要在 translate-toolkit 中為其實作支援。

檔案格式參數

File format parameters provide a way to configure settings related to the file format. They are configured at component level and allow you to customize how file parsing and serialization are handled.

List of file format parameters

參數名稱

檔案格式

標籤

幫助文字

csv_encoding

  • csv

  • csv-multi

檔案編碼方式

用於 CSV 檔案的編碼方式

可用的選擇:

auto

自動偵測

utf-8

UTF-8

csv_simple_encoding

  • csv-simple

檔案編碼方式

用於簡單 CSV 檔案的編碼方式

可用的選擇:

auto

自動偵測

utf-8

UTF-8

iso-8859-1

ISO-8859-1

dos_eol

所有檔案格式

DOS 列尾字元

Use DOS line endings (rn) instead of UNIX line endings (n) in strings.

flatxml_key_name

  • flatxml

FlatXML 鍵名稱

flatxml_root_name

  • flatxml

FlatXML 根元素名稱

flatxml_value_name

  • flatxml

FlatXML 數值名稱

gwt_encoding

  • gwt

檔案編碼方式

用於 GWT Properties 檔案的編碼方式

可用的選擇:

utf-8

UTF-8

iso-8859-1

ISO-8859-1

json_indent

  • json

  • json-nested

  • webextension

  • i18next

  • i18nextv4

  • arb

  • go-i18n-json

  • go-i18n-json-v2

  • formatjs

  • gotext

JSON 縮排

json_indent_style

  • json

  • json-nested

  • webextension

  • i18next

  • i18nextv4

  • arb

  • go-i18n-json

  • go-i18n-json-v2

  • formatjs

  • gotext

JSON 縮排類型

可用的選擇:

spaces

空白

tabs

定位字元

json_sort_keys

  • json

  • json-nested

  • webextension

  • i18next

  • i18nextv4

  • arb

  • go-i18n-json

  • go-i18n-json-v2

  • formatjs

  • gotext

排序 JSON 金鑰

json_use_compact_separators

  • json

  • json-nested

  • webextension

  • i18next

  • i18nextv4

  • arb

  • go-i18n-json

  • go-i18n-json-v2

  • formatjs

  • gotext

分隔符號後不要有空白

line_max_length

  • markdown

  • mdx

Maximum line length

The maximum number of characters for each line in the output file.

md_extract_code_blocks

  • markdown

  • mdx

Extract code blocks

Whether to extract translatable content from code blocks in Markdown and MDX files.

md_extract_frontmatter

  • markdown

  • mdx

Extract front matter

Whether to extract and translate YAML front matter blocks in Markdown and MDX files.

md_no_placeholders

  • markdown

  • mdx

Disable placeholders

Disables detection and processing of placeholders in Markdown and MDX files.

merge_duplicates

  • markdown

  • mdx

  • html

  • txt

  • dokuwiki

  • mediawiki

  • asciidoc

移除重複的相同字串

將相同的來源字串合併為單一翻譯單元。透過移除與位置相關的情境,避免在檔案重整或表格重新排序時造成翻譯遺失。

po_fuzzy_matching

  • po

使用模糊比對

po_keep_previous

  • po

保留翻譯字串上次的 msgid

po_line_wrap

  • po

  • po-mono

長列換列

By default, gettext wraps lines at 77 characters and at newlines. With the --no-wrap parameter, wrapping is only done at newlines.

可用的選擇:

77

於第 77 個字元處與新列處換列(xgettext 預設值)

65535

Only wrap lines at newlines (like xgettext --no-wrap)

-1

不要換行

po_no_location

  • po

不在檔案中納入位置資訊

po_report_msgid_bugs_to

  • po

  • po-mono

Report msgid bugs to

Lets Weblate update the "Report-Msgid-Bugs-To" file header if Source string bug reporting address is set.

po_set_language_team

  • po

  • po-mono

Update language team header

Lets Weblate update the "Language-Team" file header.

po_set_last_translator

  • po

  • po-mono

Update last translator header

Lets Weblate update the "Last-Translator" file header.

po_set_x_generator

  • po

  • po-mono

Update X-Generator header

Lets Weblate update the "X-Generator" file header.

properties_encoding

  • properties

檔案編碼方式

Java 屬性檔案使用的編碼方式

可用的選擇:

iso-8859-1

ISO-8859-1

utf-8

UTF-8

utf-16

UTF-16

strings_encoding

  • strings

檔案編碼方式

用於 iOS 字串檔案的編碼方式

可用的選擇:

utf-8

UTF-8

utf-16

UTF-16

xml_closing_tags

  • ts

  • plainxliff

  • xliff

  • xliff2

  • xliff2-placeables

  • poxliff

  • apple-xliff

  • resx

  • aresource

  • moko-resource

  • cmp-resource

  • tbx

包含空白 XML 標記的結束標記

yaml_indent

  • yaml

  • ruby-yaml

YAML 縮排

yaml_line_break

  • yaml

  • ruby-yaml

換行符號

可用的選擇:

dos

DOS (\r\n)

unix

UNIX (\n)

mac

MAC (\r)

yaml_line_wrap

  • yaml

  • ruby-yaml

長列換列

可用的選擇:

80

於第 80 個字元處折行

100

於第 100 個字元處折行

120

於第 120 個字元處折行

180

於第 180 個字元處折行

65535

不要換行