語言定義

為了恰當地呈現不同的翻譯,需要提供有關語言名稱、文本方向、複數定義和語言代碼的信息。

Built-in language definitions

Weblate 中包括了大約 600 種語言的定義,並且每次發佈時列表都在擴大。無論何時更新 Weblate 時(更特別地是無論何時執行 weblate migrate`時,請參見 :ref:`generic-upgrade-instructions)。語言數據庫都被更新,來包括 Weblate 上市時的所有語言定義。

這個特性可以使用 UPDATE_LANGUAGES`來禁止。還可以使用 :djadmin:`setuplang 來強制更新數據庫,從而匹配 Weblate 內建數據。

Parsing language codes

While parsing translations, Weblate attempts to map language code (usually the ISO 639-1 one) from the 文件掩碼 to any existing language object.

您可以通過 語言別名 在項目層次來進一步調整這種映射。

如果無法找到精確的匹配,將嘗試把其融入一種現有的語言。已嘗試以下措施:

  • 大小寫不敏感的查詢。

  • Normalizing underscores and dashes.

  • Looking up built-in language aliases.

  • Looking up by language name.

  • 忽略給定語言的默認國家代碼 — 選擇 cs 而非 cs_CZ

如果這也失敗了,將使用默認值創建一個新的語言定義 (從左到右的文本方向,一個複數)。自動創建的帶有代碼 xx_XX 的語言將被命名為 xx_XX (generated)。您可能想稍後在管理界面中更改這個(見:ref:changing-languages),並將它報告給問題跟踪器(見:ref:contributing),這樣的話,正確的定義就可以添加到即將發布的Weblate版本中。

提示

在您看到有些不想要的內容作為語言的情況下,您會想要調整 語言篩選,當分析翻譯時忽略這樣的文件。

Changing language definitions

您可以在語言界面來更改語言定義( /languages/ URL )。

當編輯時,確認所有字段都是正確的(特別是複數和正文方向),否則譯者將不能正常編輯這些翻譯。

Ambiguous language codes and macrolanguages

In many cases it is not a good idea to use macrolanguage code for a translation. The typical problematic case might be Kurdish language, which might be written in Arabic or Latin script, depending on actual variant. To get correct behavior in Weblate, it is recommended to use individual language codes only and avoid macrolanguages.

也參考

宏語言定義 <https://iso639-3.sil.org/about/scope#Macrolanguages>宏語言列表 <https://iso639-3.sil.org/code_tables/macrolanguage_mappings/data>

語言定義

每種語言都包括後面的字段:

語言碼

Code identifying the language. Weblate prefers two letter codes as defined by ISO 639-1, but uses ISO 639-2 or ISO 639-3 codes for languages that do not have two letter code. It can also support extended codes as defined by BCP 47.

語言名稱

語言的可見名稱。還要根據用戶界面語言將 Weblate 中包括的語言名稱進行本地化。

文字方向

確定語言是從右向左還是從左向右書寫。對於多數語言這個屬性都能夠正確地自動監測。

複數數量

語言中使用的複數的數量。

複數公式

Gettxt 兼容的複數公式,用於確定根據給定的數量使用哪種複數形式。

添加新的翻譯

在 2.18 版本變更: 在 2.18 以前的版本中,添加新的翻譯的行為因文件格式而不同。

Weblate 可以為所有文件格式自動開始新的翻譯。

Some formats expect to start with an empty file and only translated strings to be included (for example 安卓字符串資源), while others expect to have all keys present (for example GNU gettext). The document-based formats (for example OpenDocument Format) start with a copy of the source document and all strings marked as needing editing. In some situations this really doesn’t depend on the format, but rather on the framework you use to handle the translation (for example with JSON files).

當在 組件配置 中指定 新翻譯的模板 時,Weblate 將使用這個文件開始新的翻譯。當執行時任何現有翻譯將從文件中刪除。

新翻譯的模板 是空的,並且文件格式支持時,新建空文件,一旦新的字符串被翻譯就添加進去。

語言代碼風格 允許在生成的文件名中將語言代碼個性化:

預設基於檔案格式

依賴於文件格式,對於其中的多數使用 POSIX。

POSIX 風格使用底線當作分隔符

典型地由 gettext 和相關工具使用,生成像 pt_BR 那樣的語言代碼。

POSIX 風格使用底線當作分隔符,包含地區碼

POSIX 風格的語言代碼即使不必要時也包括國家代碼;例如 cs_CZ)。

BCP 風格使用連字號當作分隔符

典型地在 web 平台上使用,生成像 pt-BR 那樣的語言編碼。

BCP 風格使用連字號當作分隔符,包含地區碼

BCP 風格的語言代碼即使不必要時也包括國家代碼;例如 cs-CZ)。

BCP 風格:使用連字號作為分隔符,舊式語言代碼

Uses legacy codes for Chinese and BCP style notation.

BCP 風格:使用連字號作為分隔符,小寫

BCP style notation, all in lower case (for example cs-cz).

Apple App Store metadata style

Style suitable for uploading metadata to Apple App Store.

Google Play metadata style

Style suitable for uploading metadata to Google Play Store.

Android 風格

只在安卓 apps 中使用,生成像 pt-rBR 那樣的語言代碼。

Linux 風格

Locales as used by Linux, uses legacy codes for Chinese and POSIX style notation.

此外,語言別名 中定義的任何映射都反向應用。

備註

Weblate 當解析翻譯文件是識別所有這些,上面的設置只影響如何新建新的文件。