Problem with Language translation

You shouldn’t be editing the core translation files to translate a plug-in or theme. Here’s a (not so brief) run-down of how translations of plug-ins and themes work…. When a theme or plug-in wants to allow some text to be translated it wraps it inside a function like __(‘This text can be translated’,’my-theme-or-plugin’); Translation functions … Read more

WPML icl_register_string() throws fatal error but works [closed]

You should always use the wpml functions as following: (the HowTo linked by you actually suggests this 🙂 if( function_exists(‘icl_register_string’) ) { icl_register_string( ‘Match Previous Order’ , ‘match_order’, ‘Do you want these items to match a previous order from Direct Linen? If yes, use “Additional Notes” to explain.’ ); } This will ensure that you … Read more

How to define theme translation file?

It all depends a bit if your current theme already supports localization. Does your theme’s function file contain something like this? load_theme_textdomain( ‘twentytwelve’, get_template_directory() . ‘/languages’ ); If not, add it in there. And change twentytwelve to your theme-directory-name. After that create a directory called languages in the root of your theme a drop your … Read more

mo / po translation files does not seem to work

Check the wp-config.php file and see if your language is defined : define(‘WPLANG’, ‘your_language’); You could add this if you’re still stuck: add_action(‘after_setup_theme’,’wpse_110727_translate_theme’); function wpse_110727_translate_theme() { load_theme_textdomain( ‘textdomain’, get_template_directory() . ‘/languages’ ); $locale = get_locale(); $locale_file = get_template_directory() . “/languages/$locale.php”; if ( is_readable( $locale_file ) ) require_once( $locale_file ); } Just put the translation files … Read more

Translate arguments of a user added custom code [closed]

Because you are hardcoding the link, you will need to use icl_link_to_element() function and wrap any text you want to translate inside a gettext function: <?php icl_link_to_element( ‘ID_of_your_news_page’, ‘page’, ‘<h4>’ . __(‘News’) . ‘</h4>’ ); ?> This way you will get the correct version of the link based on the current language with the text … Read more

Post types translation

Use get_post_types( [‘public’ => TRUE ], ‘objects’ );. This will return the already translated post type labels and other information. Example for tests: add_action( ‘wp_footer’, function() { $post_types = get_post_types( [ ‘public’ => TRUE, ‘_builtin’ => TRUE ], ‘objects’ // complete information, not just the name ); foreach ( $post_types as $slug => $arguments ) … Read more

Programmatically choose language for translation

After looking at the l10n.php I found a way to switch the textdomain using the unload_textdomain function. So I created a simple switch function switch_textdomain( $domain, $newLocale){ /* This will only change the textdomain, not the locale. It will only affect what kind of language will be used for the _e(), _(), __() commands for … Read more

How to use esc_attr__ with custom translation function?

As your function returns the translated string, you could pass the translation function as parameter for esc_attr() and esc_attr_e(): esc_attr__( __myfunction( ‘no_comments’ ) ); esc_attr_e( __myfunction( ‘no_comments’ ) ); But esc_attr__() and esc_attr_e() will perform translation tasks that you don’t need because you handle the translation at your own, so I think it is better … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)