在地化檔案格式

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.

雙語言和單語言格式

Both monolingual and bilingual formats are supported. Bilingual formats store two languages in single file—source and translation (typical examples are GNU gettext PO (Portable Object), XLIFF 1.1 與 1.2 or 蘋果 iOS 字串). On the other side, monolingual formats identify the string by ID, and each language file contains only the mapping of those to any given language (typically Android 字串資源). Some file formats are used in both variants, see the 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 單語言基底語言檔案 within Weblate, though the naming might vary in your paradigm.

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

字串狀態

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.

目前僅在 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 格式.

唯讀的字串

Read-only strings from translation files will be included, but can not be edited in Weblate. This feature is natively supported by few formats (XLIFF 1.1 與 1.2 and Android 字串資源), but can be emulated in others by adding a read-only flag, see 使用旗標自訂行為.

支援其他格式

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.

檔案格式參數清單

參數名稱

檔案格式

標籤

幫助文字

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 列尾字元

在字串中使用 DOS 換行符號(rn),而不使用 UNIX 換行符號(n)。

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

最大列寬

輸出檔案中每一列的最大字元數。

md_extract_code_blocks

  • markdown

  • mdx

擷取程式碼區塊

是否要從 Markdown 與 MDX 檔案的程式碼區塊中擷取可翻譯內容。

md_extract_frontmatter

  • markdown

  • mdx

擷取前置資料

是否要擷取並翻譯 Markdown 與 MDX 檔案中的 YAML front matter 區塊。

md_no_placeholders

  • markdown

  • mdx

停用佔位字元

停用在 Markdown 與 MDX 檔案中偵測與處理預留位置。

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

報告 msgid 錯誤至

若已設定來源字串的錯誤報告位址,允許 Weblate 更新檔案標頭中的「Report-Msgid-Bugs-To」。

po_set_language_team

  • po

  • po-mono

更新語言團隊標頭

讓 Weblate 更新「Language-Team」檔案標頭。

po_set_last_translator

  • po

  • po-mono

更新最新譯者標頭

讓 Weblate 更新「Last-Translator」檔案標頭。

po_set_x_generator

  • po

  • po-mono

更新 X-Generator 標頭

讓 Weblate 更新「X-Generator」檔案標頭。

properties_encoding

  • properties

檔案編碼方式

Java Properties 檔案使用的編碼方式

可用的選擇:

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

不要換行