Automattic\WooCommerce\Internal\Jetpack
JetpackConnection::get_wpcom_locale
Return a locale string for wpcom.
Method of the class: JetpackConnection{}
No Hooks.
Returns
String.
Usage
$result = JetpackConnection::get_wpcom_locale();
JetpackConnection::get_wpcom_locale() JetpackConnection::get wpcom locale code WC 10.7.0
private static function get_wpcom_locale() {
// List of locales that should be used with region code.
$locale_to_lang = array(
'bre' => 'br',
'de_AT' => 'de-at',
'de_CH' => 'de-ch',
'de' => 'de_formal',
'el' => 'el-po',
'en_GB' => 'en-gb',
'es_CL' => 'es-cl',
'es_MX' => 'es-mx',
'fr_BE' => 'fr-be',
'fr_CA' => 'fr-ca',
'nl_BE' => 'nl-be',
'nl' => 'nl_formal',
'pt_BR' => 'pt-br',
'sr' => 'sr_latin',
'zh_CN' => 'zh-cn',
'zh_HK' => 'zh-hk',
'zh_SG' => 'zh-sg',
'zh_TW' => 'zh-tw',
);
$system_locale = get_locale();
if ( isset( $locale_to_lang[ $system_locale ] ) ) {
// Return the locale with region code if it's in the list.
return $locale_to_lang[ $system_locale ];
}
// If the locale is not in the list, return the language code only.
return explode( '_', $system_locale )[0];
}