Title: Automatic Variants for GlotPress
Author: Pedro Mendonça
Published: <strong>2021 年 12 月 15 日</strong>
Last modified: 2022 年 8 月 10 日

---

搜尋外掛

![](https://ps.w.org/gp-automatic-variants/assets/banner-772x250.png?rev=2822016)

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/gp-automatic-variants/assets/icon-256x256.png?rev=2769236)

# Automatic Variants for GlotPress

 由 [Pedro Mendonça](https://profiles.wordpress.org/pedromendonca/) 開發

[下載](https://downloads.wordpress.org/plugin/gp-automatic-variants.1.0.0.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/gp-automatic-variants/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/gp-automatic-variants/#reviews)
 * [開發資訊](https://tw.wordpress.org/plugins/gp-automatic-variants/#developers)

 [技術支援](https://wordpress.org/support/plugin/gp-automatic-variants/)

## 外掛說明

這個 GlotPress 的擴充功能外掛可以自訂一組選取地區語言 (最上層地區語言/語言變體) 
的預設行為，讓使用者將最上層地區語言中的已核准/目前譯文字串自動轉換至其變體語言。

這個外掛會使用 GlotPress 持續將最上層地區語言的譯文自動轉換並同步至其語言變體的譯文。

只有與最上層地區語言譯文不同的譯文，才會新增至變體語言譯文集。

變體語言中不需要轉換的字串會保持未翻譯的狀態，並改為使用最上層地區語言的譯文。

這個外掛主要受到[塞爾維亞拉丁文](https://meta.trac.wordpress.org/ticket/5471)從[塞爾維亞斯拉夫文進行音譯](https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/locales/class-serbian-latin.php?rev=10360)
解決方案的啟發。

### 外掛功能

 * 篩選器 `gp_automatic_variants_list` 可以將語言變體新增至自動轉換的語言變體陣列。
 * 篩選器 `gp_automatic_variants_convert_{variant_locale}` 可以處理變體語言的字串
   自動轉換。
 * 檢查 GlotPress 的最低安裝需求。
 * 檢查新增的地區語言是否為 GlotPress 支援的語言變體。
 * 轉換最上層地區語言的`目前譯文`，並新增至變體語言的譯文集。
 * 刪除不再使用的語言變體譯文，而不是保留`已駁回的譯文`、`模糊翻譯譯文`及`前版譯文`。
 * 當最上層地區語言的新增譯文具備相同 `original_id` 則不進行轉換，並刪除語言變體
   的`目前譯文`。

### 安裝 GlotPress

 1. 安裝並啟用 GlotPress 3.0.0-alpha。
 2. 在 [外掛] 頁面中安裝並啟用這個外掛。

### 為 GlotPress 的自動語言變體進行組態

 1. 使用篩選器 `gp_automatic_variants_list` 依據需求設定要自動轉換的語言變體：
 2.     ```
        /**
         * Add my automatically converted variants.
         */
        function my_automatic_variants( $locales ) {
            $additional_locales = array(
                'ca-valencia',
                'pt-ao90',
                'ca-valencia',
                'en-gb',
                'de-at',
                'de-ch',
            );
            return array_merge( $locales, $additional_locales );
        }
    
        add_filter( 'gp_automatic_variants_list', 'my_automatic_variants' );
        ```
    
 3. 使用篩選器 `gp_automatic_variants_convert_{variant_locale}` 將指定的地區語言加入
    至轉換程序中：
 4. 語言變體 `pt-ao90` 的範例：
 5.     ```
        /**
         * Actual conversion of the string.
         */
        function convert_translation( $translation ) {
            return do_something( $translation );
        }
    
        add_filter( 'gp_automatic_variants_convert_pt-ao90', 'convert_translation' );
        ```
    
 6. 
    ### 使用方式
    
 7. 對全部的本地化專案來說，如常新增最上層地區語言及語言變體的譯文集即可。
 8. 僅需為最上層地區語言進行本地化，然後查看譯文是否自動轉換至語言變體即可。

### 環境需求

 * 支援語言變體的 [GlotPress 3.0.0-alpha](https://github.com/GlotPress/GlotPress/releases/tag/3.0.0-alpha.4)。

## 常見問題集

### 這個外掛的實際功能為何？

這個外掛擴充了用於本地化 WordPress 專案的 GlotPress 本地化平台。
 GlotPress 3.x 
推出了全新的語言變體功能，可將某些地區語言設定為最上層語言的語言變體：基於這項功能，
最上層地區語言可作為語言變體的後援語言。 如果語言變體中有不存在的譯文，便會套用其
最上層地區語言的譯文。 這個外掛可以將多個地區語言進行連結，使用者僅需要專注於最上層
地區語言的翻譯及一致性管理，這代表最上層地區語言的譯文會自動轉換並同步至語言變體，
無須任何人工介入。 使用這個工具，便能以最少心力持續提供多個地區語言的譯文。

### translate.wp.org 支援自動轉換語言變體嗎？

尚未支援。這僅是可運作的概念驗證，並可在 GlotPress 外掛版本 3.x 上運作，但以 GlotPress
為基礎建置的 [translate.wp.org](https://translate.wp.org) 目前不提供這項支援。

### 這個功能應該納入 GlotPress 外掛版本嗎？

有待後續討論。
 最上層地區語言及其語言變體的關係，取決於使用 GlotPress 的每個本地
化團隊。 本地化團隊的工作方式，會讓需要自動轉換功能的團隊，就覺得很實用。 對於需要
最上層地區語言/語言變體自動運作的本地化團隊而言，GlotPress 整合這個選用功能後，便能
將指定的語言變體從關聯的最上層地區語言自動轉換而來，並將語言變體設定為唯讀。 任何
想要在最上層地區語言及其語言變體進行自動轉換的本地化團隊，都可以使用這項功能。 這個
外掛的開發目的，在於驗證使用及測試這個概念的工作流程。

### 這個外掛與 GlotPress 哪個版本相容？

[GlotPress 3.0.0-alpha](https://github.com/GlotPress/GlotPress/releases/tag/3.0.0-alpha.4)
導入語言變體功能。
 但在之後的 [GlotPress 3.0.0-beta](https://github.com/GlotPress/GlotPress/releases/tag/3.0.0-beta.1)
中[暫時移除](https://github.com/GlotPress/GlotPress/pull/1327)這項功能，因此 GlotPress
3.0.0-alpha 是唯一具備語言變體功能的版本，必須安裝這個版本才能體驗這項功能。

### 如何參與這個外掛開發專案？

非常歡迎前往這個外掛的 [GitHub 存放庫](https://github.com/pedro-mendonca/GP-Automatic-Variants)
回報問題或提出功能建議。

## 使用者評論

這個外掛目前沒有任何使用者評論。

## 參與者及開發者

以下人員參與了開源軟體〈Automatic Variants for GlotPress〉的開發相關工作。

參與者

 *   [ Pedro Mendonça ](https://profiles.wordpress.org/pedromendonca/)

〈Automatic Variants for GlotPress〉外掛目前已有 9 個本地化語言版本。 感謝[全部譯者](https://translate.wordpress.org/projects/wp-plugins/gp-automatic-variants/contributors)
為這個外掛做出的貢獻。

[將〈Automatic Variants for GlotPress〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/gp-automatic-variants)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/gp-automatic-variants/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/gp-automatic-variants/)，或透過
[RSS](https://plugins.trac.wordpress.org/log/gp-automatic-variants/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/gp-automatic-variants/)。

## 變更記錄

#### 1.0.0

 * Initial release.
 * 篩選器 `gp_automatic_variants_list` 可以將語言變體新增至自動轉換的語言變體陣列。
 * 篩選器 `gp_automatic_variants_convert_{variant_locale}` 可以處理變體語言的字串
   自動轉換。
 * 檢查 GlotPress 的最低安裝需求。
 * 檢查新增的地區語言是否為 GlotPress 支援的語言變體。
 * 轉換最上層地區語言的`目前譯文`，並新增至變體語言的譯文集。
 * 刪除不再使用的語言變體譯文，而不是保留`已駁回的譯文`、`模糊翻譯譯文`及`前版譯文`。
 * 當最上層地區語言的新增譯文具備相同 `original_id` 則不進行轉換，並刪除語言變體
   的`目前譯文`。

## 中繼資料

 *  版本 **1.0.0**
 *  最後更新 **4 年前**
 *  啟用安裝數 **少於 10 次**
 *  WordPress 版本需求 ** 5.3 或更新版本 **
 *  已測試相容的 WordPress 版本 **5.8.13**
 *  PHP 版本需求 ** 7.2 或更新版本 **
 *  語言
 * [Chinese (Taiwan)](https://tw.wordpress.org/plugins/gp-automatic-variants/)、
   [Dutch (Belgium)](https://nl-be.wordpress.org/plugins/gp-automatic-variants/)、
   [English (US)](https://wordpress.org/plugins/gp-automatic-variants/)、[Italian](https://it.wordpress.org/plugins/gp-automatic-variants/)、
   [Portuguese (Portugal)](https://pt.wordpress.org/plugins/gp-automatic-variants/)、
   [Spanish (Chile)](https://cl.wordpress.org/plugins/gp-automatic-variants/)、[Spanish (Colombia)](https://es-co.wordpress.org/plugins/gp-automatic-variants/)、
   [Spanish (Ecuador)](https://es-ec.wordpress.org/plugins/gp-automatic-variants/)、
   [Spanish (Spain)](https://es.wordpress.org/plugins/gp-automatic-variants/)、及
   [Spanish (Venezuela)](https://ve.wordpress.org/plugins/gp-automatic-variants/).
 *  [將這個外掛本地化為你的母語版本](https://translate.wordpress.org/projects/wp-plugins/gp-automatic-variants)
 * 標籤:
 * [glotpress](https://tw.wordpress.org/plugins/tags/glotpress/)[localization](https://tw.wordpress.org/plugins/tags/localization/)
   [translation](https://tw.wordpress.org/plugins/tags/translation/)[variants](https://tw.wordpress.org/plugins/tags/variants/)
 *  [進階檢視](https://tw.wordpress.org/plugins/gp-automatic-variants/advanced/)

## 評分

這個項目尚無任何評論記錄。

[Your review](https://wordpress.org/support/plugin/gp-automatic-variants/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/gp-automatic-variants/reviews/)

## 參與者

 *   [ Pedro Mendonça ](https://profiles.wordpress.org/pedromendonca/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/gp-automatic-variants/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](https://github.com/sponsors/pedro-mendonca)