Automattic\WooCommerce\Admin\API
OnboardingPlugins::get_wpcom_locale()
Return a locale string for wpcom.
Method of the class: OnboardingPlugins{}
No Hooks.
Return
String
.
Usage
// private - for code of main (parent) class only $result = $this->get_wpcom_locale();
OnboardingPlugins::get_wpcom_locale() OnboardingPlugins::get wpcom locale code WC 9.7.1
private 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]; }