-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5c0423
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
=== Simple Admin Language Change === | ||
Contributors: vyskoczilova | ||
Tags: translation, translations, i18n, admin, english, localization, backend, simple, change, admin, language, administration, locale | ||
Requires at least: 4.0 | ||
Tested up to: 4.7.2 | ||
Stable tag: /trunk | ||
License: GPLv3 | ||
License URI: http://www.gnu.org/licenses/gpl-3.0.html | ||
GitHub Plugin URI: https://github.com/vyskoczilova/Simple-Admin-Language-Change/ | ||
|
||
Simple and lightweight solution for changing the language of the admin area. Front site locale and language remain unchanged. | ||
|
||
== Description == | ||
|
||
Have you ever struggled with setting up a theme or plugin because of bad localisation? Not corresponding to the manual or documentation? Googling for How to's but your web has different locale and you don't want to switch between them? | ||
|
||
This simple and lightweight plugin allows you to set locale for admin area only (except General Options page) and keep it separate from your page locale. Simple and easy. Automatically set to English, but you can change it in the General Options page settings. | ||
|
||
Applies only to administrator accounts. | ||
|
||
Do you want help with the development? Join the Github: https://github.com/vyskoczilova/Simple-Admin-Language-Change/ | ||
|
||
== Installation == | ||
= EN = | ||
1. Upload the plugin to your website or install via plugin management. | ||
1. Check whether the WooCommerce plugin is installed and active. | ||
1. Activate the plugin through the `Plugins` menu in WordPress administration | ||
1. (If you wish, go to the `Settings` and `General` to select different installed language instead of English) | ||
1. Done! | ||
|
||
== Screenshots == | ||
|
||
1. Settings of Admin language in General Settings. | ||
|
||
== Changelog == | ||
|
||
= 1.0.0 (2016-10-06) = | ||
* Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Simple Admin Language Change | ||
* Plugin URI: http://kybernaut.cz/pluginy/simple-admin-language-change | ||
* Description: Change your admin language easily. | ||
* Version: 1.0.0 | ||
* Author: Karolína Vyskočilová | ||
* Author URI: http://www.kybernaut.cz | ||
* Text Domain: kbnt-scal | ||
* License: GPLv3 | ||
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | ||
* Domain Path: /languages | ||
*/ | ||
|
||
|
||
// If this file is called directly, abort. | ||
if ( ! defined( 'WPINC' ) ) { | ||
die; | ||
} | ||
|
||
|
||
// ============================================================================= | ||
// ACTIONS | ||
// ============================================================================= | ||
|
||
function admin_language_loaded() { | ||
|
||
$new_general_setting = new admin_language_new_general_setting(); | ||
add_filter('locale', 'admin_language_setLocale'); | ||
|
||
} | ||
add_action( 'plugins_loaded', 'admin_language_loaded' ); | ||
|
||
|
||
// ============================================================================= | ||
// FUNCTIONS | ||
// ============================================================================= | ||
|
||
function admin_language_setLocale( $locale ) { | ||
|
||
global $pagenow; | ||
|
||
if ( is_admin() && $pagenow != 'options-general.php' && current_user_can('administrator') ) { | ||
$locale_admin = get_option( 'WPLANG_ADMIN', 'en_US' ); | ||
return $locale_admin; | ||
} | ||
|
||
return $locale; | ||
} | ||
|
||
// ============================================================================= | ||
// CLASSES | ||
// ============================================================================= | ||
|
||
class admin_language_new_general_setting { | ||
|
||
function admin_language_new_general_setting( ) { | ||
add_filter( 'admin_init' , array( &$this , 'admin_language_register_fields' ) ); | ||
} | ||
function admin_language_register_fields() { | ||
register_setting( 'general', 'WPLANG_ADMIN', 'esc_attr' ); | ||
add_settings_field('admin_language', '<label for="WPLANG_ADMIN">'.__('Admin Language' , 'kbnt-scal' ).'</label>' , array(&$this, 'admin_language_fields_html') , 'general'); | ||
} | ||
function admin_language_fields_html() { | ||
|
||
$locale = get_option( 'WPLANG_ADMIN', 'en_US' ); | ||
|
||
$languages = get_available_languages(); | ||
$translations = wp_get_available_translations(); | ||
if ( ! is_multisite() && defined( 'WPLANG_ADMIN' ) && '' !== WPLANG_ADMIN && 'en_US' !== WPLANG_ADMIN && ! in_array( WPLANG_ADMIN, $languages ) ) { | ||
$languages[] = WPLANG; | ||
} | ||
if ( ! empty( $languages ) || ! empty( $translations ) ) { | ||
|
||
wp_dropdown_languages( array( | ||
'name' => 'WPLANG_ADMIN', | ||
'id' => 'WPLANG_ADMIN', | ||
'selected' => $locale, | ||
'languages' => $languages, | ||
'translations' => $translations, | ||
'echo' => 1, | ||
'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(), | ||
) ); | ||
|
||
} | ||
|
||
} | ||
|
||
} |