
內容簡介
這個 WordPress 的外掛程式用於自訂 GlotPress 一組選定的語言地區(根/變體)的默認行為,使您可以自動將根地區中已認可/當前的字串轉換為其變體。
它會自動將根翻譯轉換並與其所在 GlotPress 安裝的變體翻譯進行同步。
僅添加與根翻譯不同的翻譯才會添加到變體翻譯集中。
不需要轉換的字串在變體上保持未翻譯,並回退到根地區。
此外掛程式的靈感來自於來自 translate.wordpress.org 的塞爾維亞西里爾字母語言區域轉寫的解決方案。
特性
篩選器 gp_automatic_variants_list 可將您的變體添加到自動轉換變體的數組中。
篩選器 gp_automatic_variants_convert_{variant_locale} 可處理自動變體的字串轉換。
檢查 GlotPress 的最小要求。
檢查新增語言地區是否是已安裝 GlotPress 支持的變體。
轉換current的根翻譯,並添加到變體翻譯集中。
刪除未使用的變體翻譯,而不是保留為rejected,fuzzy,old。
如果添加了新的根翻譯(相同的original_id)並且不需要轉換,則刪除current變體翻譯。
安裝 GlotPress
安裝並啟用 GlotPress,最低版本為 3.0.0-alpha。
從您的外掛頁面安裝並啟用此外掛程式。
為 GlotPress 配置自動變體
使用篩選器 gp_automatic_variants_list 設置您要自動轉換的變體:
/**
* 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' );
使用篩選器 gp_automatic_variants_convert_{variant_locale} 添加您的語言地區實際轉換過程:
變體 ‘ pt-ao90 ’的例子:
/**
* Actual conversion of the string.
*/
function convert_translation( $translation ) {
return do_something( $translation );
}
add_filter( 'gp_automatic_variants_convert_pt-ao90', 'convert_translation' );
用法
對於每個翻譯項目,按照常規方式添加根和變體翻譯集。
僅對根目錄進行翻譯,查看轉換自動傳播到變體。
要求
GlotPress 3.0.0-alpha並支持變體。
外掛標籤
開發者團隊
② 後台搜尋「Automatic Variants for GlotPress」→ 直接安裝(推薦)
原文外掛簡介
This plugin for GlotPress customizes the default behavior of a set of chosen pairs of Locales (root/variant), allowing you to automatically convert the approved/current strings in the root to its variant.
It keeps the root translations automatically converted and synced with its variant translations within your GlotPress install.
The only translations added to the variant translation set are those which are different from the root translation.
The strings that don’t need any conversion remain untranslated on the variant, falling back to the root Locale.
This plugin was heavily inspired by the Serbian Latin solution for transliteration of Serbian Cyrillic locale from translate.wordpress.org.
Features
Filter gp_automatic_variants_list to add your variant to the array of automatically converted variants.
Filter gp_automatic_variants_convert_{variant_locale} to process the conversion of strings of the automatic variant.
Check for GlotPress minimum requirements.
Check if the added Locales are variants supported the installed GlotPress.
Convert current root translations and add to the variant translation set.
Delete variant unused translations instead of keeping as rejected, fuzzy, old.
Delete current variant translation if a new root translation (same original_id) is added and doesn’t need conversion.
Install GlotPress
Install and activate GlotPress 3.0.0-alpha minimum version.
Install and activate this plugin from your plugins page.
Configure Automatic Variants for GlotPress
Set the variants you want to be automatically converted with the filter gp_automatic_variants_list:
/**
* 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' );
Add your Locale actual conversion process with the filter gp_automatic_variants_convert_{variant_locale}:
Example for the variant ‘pt-ao90’:
/**
* Actual conversion of the string.
*/
function convert_translation( $translation ) {
return do_something( $translation );
}
add_filter( 'gp_automatic_variants_convert_pt-ao90', 'convert_translation' );
Usage
For every translation project, add both root and variant translation sets as usual.
Translate only on the root Locale and see the conversions automatically propagate to the variant.
Requirements
GlotPress 3.0.0-alpha with Variants support.
