I am trying to change my theme language in the frontend from english to german . I have changed also wp-config.php file . But it doesn't work. I am using wordpress 4.0
Can some one what should to do change language?
You can do the following:
Get the the language pack (e.g. de_DE.mo) from wordpress.org. 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 under wp-content/languages.
Move the .mo file to wp-content/languages/ of your default (english) WordPress installation.
Change the WPLANG constant in wp-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;
}
Reference - https://wordpress.stackexchange.com/questions/27056/different-language-for-frontend-and-backend
Take a look at WordPress Codex - Translating WordPress
Additionally you can use WP plugins especially for translating your WP website:
Codestyling Localization
User Language Switch
Setup your site in the desired language in the admin settings and then download this plugin. In it you can setup the language for your admin backend side only ;)
http://wordpress.org/extend/plugins/kau-boys-backend-localization/
You can use the google translate plugin for wordpress. For more info see the plugin page.
Google Translate WordPress » WP Translate
I wanted to change the language in the front-end and keep the language in the backend the same. I tried using adding a filter to in function.php but that didn't work for me. What did was using a plugin - Backend localization
Change Language of Woocomerce through Functions Or change language of wodpress
/* ==== Function Start ==== */
add_filter('gettext', 'translate_reply44');
add_filter('ngettext', 'translate_reply44');
function translate_reply44($translated) {
$translated = str_ireplace('Undo?', 'numaları sipariş silindi. Sepete geri almak istiyorsanız tıklayın? ', $translated);
return $translated;
}
/* ==== Function END ==== */
Since 4.7, you should do the following:
function wp_noshor_redefine_locale($locale) {
if( is_admin() ):
switch_to_locale('en_US');
endif;
}
add_filter('init','wp_noshor_redefine_locale');
this changes the dashbaord to English while setting front-end to the language you choose from the setting option.
Related
I'm trying to set the german language for the Wordpress backend.
German is also installed and can be selected under:
Settings> General> Site Language
Unfortunately it jumps back to English when saving.
My attempts so far:
The following did not work (for me):
wp_config.php WPLANG set and also removed
Looking at the database by setting, it is set to de_DE
Loco Translate installed and viewed. There, too, like the Site Language, it is output as English. Loco removed again. No WPML/Loco installed.
Checked for language updates, there were none.
Installed formal German and tried to select.
Language files controlled by FTP. Only German available, no EN.
Check latest Wordpress 5.8.
No Errors in Log Files
Test .htaccess, wp-content, wp-content/languages and all other subfolders of wp-content set to 777. Only for a sec. Really.
Deactive all Plugins
Other settings such as the time (UTC + 2) could be changed and saved
Activate all WordPress debug mode for developers. Nothing
define('FS_METHOD', 'direct'); doesnt help
Check WP site-health.
Browser-Language set to german
Try another Browser
The following did work:
Installed and activated a Wordpress original theme "Twenty One" as a test
Since only the theme change worked, it had to be due to the theme. So I scoured the files and found it here:
The code says, and this was confirmed to me by support when I asked, that if "Deactivate translations" is not active in the theme options, absolute is set to en_US.
function et_divi_maybe_change_frontend_locale( $locale ) {
$option_name = 'divi_disable_translations';
$theme_options = get_option( 'et_divi' );
$disable_translations = isset ( $theme_options[ $option_name ] ) ? $theme_options[ $option_name ] : false;
if ( 'on' === $disable_translations ) {
return 'en_US';
}
return $locale;
}
add_filter( 'locale', 'et_divi_maybe_change_frontend_locale' );
I modify wp_hash_password and wp_check_password with my own encryption password, I want to use hook now. This is to make sure when my wordpress update the latest version, my wp_hash_password and wp_check_password in pluggable.php still is my own password encryption, the hook should add at where? Look on Internet, some say put in user.php and some say put in function.php in theme. If who know, please tell me the answer.
Plugins are loaded first, then pluggable.php and then lastly the theme. Subsequently, you need to create a plugin and place your pluggable functions code in there otherwise your custom code won't be loaded. Create a file called custom_wp_password_override.php or whatever you want to label it and place it in your plugin's folder adding in your own custom function code. You should never update core files such as user.php as this will be overwritten when you upgrade WordPress.
<?php
/*
Plugin Name: Custom WordPress Passwords
Plugin URI: http://localhost
Description: Override wordpress pluggable password functions.
Version: 1.0.0
Author: Your Name
Author URI: http://locahost
Text Domain: custom-wp-passwords
*/
if ( !function_exists('wp_check_password') ) :
function wp_check_password($password, $hash, $user_id = '') {
// Your custom code in here
}
endif;
if ( !function_exists('wp_hash_password') ) :
function wp_hash_password($password) {
// Your custom code here
}
endif;
?>
So the first thing I know when into WordPress development is not to edit any files in two folders: wp-include and wp-admin. Or you will lose all your edit when update WordPress to the newer version.
Back to your question, if you think you will not change the theme in the future, put your code in child theme's functions.php. Yeah, child theme will not affect when you update your parent theme.
And I think, the best solution for you is creating a simple WordPress plugin, put your code in, and activate that plugin. So your encryption will not lose when you update WordPress core/theme/other plugins even.
<?php
/*
Plugin Name: WP Custom Plugins
Plugin URI: http://link to your plugin homepage
Description: This plugin changes WordPress hashing password encryption.
Version: 1.0
Author: Someone
Author URI: http://link to your website
License: GPL2 etc
License URI: https://link to your plugin license
/* Your code goes below here */
I've tried too much for changing the language of buddypress but failed.
I have set the language in wp-config.php
define('WPLANG', 'es_ES');
if ( file_exists( WP_LANG_DIR . '/buddypress-es_ES.mo' ) ) {
load_textdomain( 'buddypress', WP_LANG_DIR . '/buddypress-es_ES.mo' );
}
Nothing worked. Please help.
That code should be good. Why the if statement when define('WPLANG', 'es_ES'); should work properly? BuddyPress follows the language settings set by WordPress.
Verify you have the translation file uploaded via:
wp-content/languages/themes/your_theme-es_ES.mo
Also, note that if you're using WordPress v4.0 and above you can change the language in the dashboard (assuming you have the language files) via Settings > General > Site Language.
I have seen many questions and answers but none that fit the bill. So here is my issue.
I have a plugin that I have localized which works fine on it's own when you add
define('WPLANG', 'my-plugin-name-de_DE');
to the wp-config file. But then when someone try's to translate the rest of the wp site it will not show the languange.
What am I missing here? I even tried naming the files I added the the wp-content folder to be the same name as my plugin... for example my-plugin-name-de_DE.po and .mo and no luck.
ANSWER
Ok so in wordpress 4.0 you can now select your language from the settings /general page.
My plugin was localized using the code
function plugin_action_init()
{
// Localization
load_plugin_textdomain('my-plugin-name', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
// Add actions
add_action('init', 'plugin_action_init');
Example of a string that would get translated.
_e('Simple text example', 'my-plugin-name');
SO all that needed to be done to get my plugin's and wordpress's translation to work at the same time was to upload the wp language that I want to the wp-content/languages folder. Making sure the file name was simply de_DE.mo and de_DE.po
Such a simple mistake :)
I want to make a plugin for all of my own wordpress-based websites.
The idea is simple, I want to get the version (and probably another info) of those sites by using CURL.
Right now, I have such a code:
<?php
/*
Plugin Name: Manage Site
Plugin URI: http://not-available-yet.com/
Description: A manage site plugin
Author: Go Frendi Gunawan
Version: 0.0
Author URI: http://not-available-yet.com/
*/
// this file is located on wp-content/plugins/manage_site
require_once '../../../wp-includes/version.php'; // do I need to include everything manually like this?
if(isset($_GET['key']))
{
$key = $_GET['key'];
if($key=='1234'){
echo $wp_version;
}
}
And I can access it by using CURL with this address:
http://my_domain.com/wordpress/wp-content/plugins/manage_site/manage_site.php?key=1234
And I'll get the wordpress version as a response:
3.5.1
It is work for now.
But, since this is my first time writing a wordpress plugin, I might do things wrongly. So, Am I doing it right? Or is there any better way to write this?
I've found the answer.
Both, #kjetilh and #brasofilo was right in case of accessing wordpress plugin "the normal way".
Since I access the plugin directly, the wordpress bootstrap is not loaded. Therefore, my first approach was partially right.
But load the wp-load.php is more elegant (and simple and usable) since it load everything, not only the version, and it gonna be useful to access 'more information':
<?php
/*
Plugin Name: Manage Site
Plugin URI: http://not-available-yet.com/
Description: A manage site plugin
Author: Go Frendi Gunawan
Version: 0.0
Author URI: http://not-available-yet.com/
*/
// this file is located on wp-content/plugins/manage_site
require_once '../../../wp-load.php';
if(isset($_GET['key']))
{
$key = $_GET['key'];
if($key=='1234'){
echo $wp_version;
}
}