get_locale()

最后更新于:2021-11-26 09:17:34

get_locale()

Retrieves the current locale.

响应

(string) The locale of the blog or from the ‘locale’ hook.

源文件

文件: gc-includes/l10n.php

function get_locale() {
	global $locale, $gc_local_package;

	if ( isset( $locale ) ) {
		/** This filter is documented in gc-includes/l10n.php */
		return apply_filters( 'locale', $locale );
	}

	if ( isset( $gc_local_package ) ) {
		$locale = $gc_local_package;
	}

	// GCLANG was defined in gc-config.
	if ( defined( 'GCLANG' ) ) {
		$locale = GCLANG;
	}

	// If multisite, check options.
	if ( is_multisite() ) {
		// Don't check blog option when installing.
		if ( gc_installing() ) {
			$ms_locale = get_site_option( 'GCLANG' );
		} else {
			$ms_locale = get_option( 'GCLANG' );
			if ( false === $ms_locale ) {
				$ms_locale = get_site_option( 'GCLANG' );
			}
		}

		if ( false !== $ms_locale ) {
			$locale = $ms_locale;
		}
	} else {
		$db_locale = get_option( 'GCLANG' );
		if ( false !== $db_locale ) {
			$locale = $db_locale;
		}
	}

	if ( empty( $locale ) ) {
		$locale = 'en_US';
	}

	/**
	 * Filters the locale ID of the GeChiUI installation.
	 *
	 * @since 1.5.0
	 *
	 * @param string $locale The locale ID.
	 */
	return apply_filters( 'locale', $locale );
}