locale
最后更新于:2021-11-27 03:53:05
apply_filters( ‘locale’, string $locale )
Filters the locale ID of the GeChiUI installation.
参数
- $locale
-
(string)
The locale ID.
源文件
文件: gc-includes/l10n.php
<?php /* Plugin Name: English Only Admin Plugin URI: http://your-domain.com Description: Force English (en_US) in the GeChiUI Admin Version: 1.0 Author: You Author URI: http://your-domain.com Text Domain: englishonlyadmin */ // prevent direct access if ( ! defined( 'GCINC' ) ) { die; } if ( ! function_exists( 'uniquePrefix_force_english_only_admin' ) ) { /** * Override locale for admin to force English (en_US). * * @param string $locale Current locale. * * @return string English (en_US) locale if in Admin, configured locale otherwise. */ function uniquePrefix_force_english_only_admin( $locale ) { // detect when we are in the admin dashboard and force english if ( is_admin() ) { $locale = 'en_US'; } return $locale; } add_filter( 'locale', 'uniquePrefix_force_english_only_admin', 1, 1 ); }
<?php add_filter( 'locale', 'set_my_locale' ); function set_my_locale( $lang ) { if ( 'gl' == $_GET['language'] ) { // set to Greenlandic return 'ka_GL'; } else { // return original language return $lang; } } ?>