admin管理员组文章数量:1291316
I use an English WordPress package and this is very well.
Now, I would like to translate some elements of the blog (like "posted on", "comments") etc., but do leave the dashboard interface intact in English.
Is there any mechanism to translate just the site elements?
I use an English WordPress package and this is very well.
Now, I would like to translate some elements of the blog (like "posted on", "comments") etc., but do leave the dashboard interface intact in English.
Is there any mechanism to translate just the site elements?
Share Improve this question edited Aug 14, 2018 at 10:27 serge 2732 silver badges6 bronze badges asked Aug 27, 2011 at 16:42 serhioserhio 3151 gold badge4 silver badges10 bronze badges 07 Answers
Reset to default 22You can do the following:
- Get the the language pack (e.g.
de_DE.mo
) from wordpress. If the language pack isn't available as a standalone download, you could also use the.mo
file which is bundled in the WordPress ZIP-file for your language. Located underwp-content/languages
. - Move the
.mo
file towp-content/languages/
of your default (english) WordPress installation. - Change the
WPLANG
constant inwp-config.php
to the new locale (e.g.de_DE
) - In your
functions.php
add the following filter:
functions.php
add_filter('locale', 'wpse27056_setLocale');
function wpse27056_setLocale($locale) {
if ( is_admin() ) {
return 'en_US';
}
return $locale;
}
Since WordPress version 4.7, different Backend users can set their own preferred admin language using the native WordPress language selector. This way, they see the WordPress interface in their language and can more easily manage content.
In the WordPress 5.x it real simple to get a different frond and back end language
To change the site language go to Setting -> General -> Site Language and select the site language.
For the Admin Panel goto Users -> Your Profile and select the language you want to have on the Admin Panel
So all the above solutions have become absolute, each user can set their own language for the WordPress interface
You can use plugins for that: http://wordpress/extend/plugins/kau-boys-backend-localization/ or http://wordpress/extend/plugins/wp-native-dashboard/
If anyone is still looking for that, here is what you should do since version 4.7
function wp_noshor_redefine_locale($locale) {
if( is_admin() ):
switch_to_locale('en_US');
endif;
}
add_filter('init','wp_noshor_redefine_locale');
This forces the dashboard to load in English, then you can go to settings, set the language you desire.
An updated answer for Wordpress 4+
@rofflox's answer is still correct, but there have been some changes to Wordpress that can have an effect when using his function 'as-is' since WP 4.0.
The wp-config constant WPLANG
has been deprecated in favour of setting the site language via a dropdown in Settings->General
. This means that, after changing your site's language to Svenka (for example), your site's admin will appear in English... but that Site Language dropdown in Settings->General
will be pre-selected as English (United States). That means that, if you make changes to your General settings later on and forget to pick Svenka as your site's language again, the whole site will revert back to English.
I would recommend creating functions in your functions.php
file like so:
// Set the locale; original function from @rofflox
function vnmFunctionality_setLocale($locale) {
if (is_admin()) {
return 'en_US';
}
return $locale;
}
add_filter('locale', 'vnmFunctionality_setLocale');
// Enqueue a script to force-set the Language dropdown on the General Options page, just in case we forget about it later.
function vnmFunctionality_countryReminderScript($hook) {
if ($hook != 'options-general.php') {
return;
}
wp_enqueue_script('lang-reminder-script', get_template_directory() . '/js/site-language.js', array('jquery'), '1.0.0', true);
wp_localize_script('lang-reminder-script', 'langObject', array(
'lang' => get_option('WPLANG'),
));
}
add_action('admin_enqueue_scripts', 'vnmFunctionality_countryReminderScript');
And then a Javascript file called site-language.js
(saved in a /js/
folder in your theme) like so:
jQuery(document).ready(function($) {
$('select#WPLANG').val(langObject.lang).change();
});
This should automatically pre-select the site's current display language in the dropdown on the Options page, so that you don't have to remember to do it manually every time.
What you need is to translate your theme. If your theme has a .pot file then it is easy to translate. Just follow the steps at
http://www.appthemes/blog/how-to-translate-a-wordpress-theme/
Else, you will need to edit the theme files and change the words at each instance.
本文标签: translationDifferent Language for Frontend vs Backend
版权声明:本文标题:translation - Different Language for Frontend vs Backend 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741530485a2383727.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论