Automattic\WooCommerce\Admin\API

OnboardingPlugins::get_wpcom_locale()privateWC 1.0

Return a locale string for wpcom.

Метод класса: OnboardingPlugins{}

Хуков нет.

Возвращает

Строку.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_wpcom_locale();

Код OnboardingPlugins::get_wpcom_locale() 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];
}