Skip to content

Commit

Permalink
veversion 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Jan 31, 2017
0 parents commit b5c0423
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
38 changes: 38 additions & 0 deletions readme.txt
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
89 changes: 89 additions & 0 deletions simple-admin-language-change.php
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(),
) );

}

}

}

0 comments on commit b5c0423

Please sign in to comment.