Locale filter in conjunction with new datepicker localization

I was able to successfully change the datepicker’s strings to a different locale for a single page using the switch_to_locale() function introduced in WordPress v4.7. switch_to_locale() will modify the global $wp_locale variable which is used by wp_localize_jquery_ui_datepicker(). Changing the locale with the locale filter alone does not overwrite $wp_locale. /** * Use switch_to_locale() on a … Read more

Override plugin localization

From what you are saying you have translated your plugin and now you want to be sure the future update won’ be overwritten. So to avoid that happening you can always put your po/mo translation files (if provided) in global languages folder that is located on your server in wp-content/languages/plugins folder. If plugin have language … Read more

Can we use a variable hook for language string?

Yes this is problematic as i18n tools that parse your theme to generate a *.pot file for translation can’t understand this as they do not run PHP code but just search your code as text. Here is a blogpost detailing on why this may cause trouble: Bottom line: Inside all translation functions, no PHP variables … Read more

Using plural-only translation of register_post_status() in plugin

// Get the plural post status label $ps_status_label = $status->label_count; $submenu[$menu][] = array( sprintf( translate_nooped_plural( $ps_status_label, $ps_status_count ), $ps_status_count ), This should work as expected for the core translations. Now you need the textdomain, so lets search for the string you wish to translate foreach ( $GLOBALS[‘l10n’] as $domain => $data ) { if ( … Read more

localize inline css

You could use the wp_head hook and inject your <style> tag directly into the <head>. Note: make sure you’re firing the wp_head() function in your template (which you should be doing already). add_action(‘wp_head’, ‘random_background_image_wpse_83275’); function random_background_image_wpse_83275() { $images = array( ‘/path/to/image1.jpg’, ‘/path/to/image2.jpg’, ‘/path/to/image3.jpg’, ‘/path/to/image4.jpg’, ); $image = $images[rand(0, count($images)-1)]; echo ‘ <style> html { background: … Read more

Can we load “load_theme_textdomain” multiple times with different domains?

Note that if you put your mo-files inside your theme’s directory, the same mo-file will be loaded for every theme textdomain. That is because a theme mo-file is based solely on the locale. For example: load_theme_textdomain( ‘basic’, get_template_directory() . ‘/languages’ ); load_theme_textdomain( ‘advance’, get_template_directory() . ‘/languages’ ); load_theme_textdomain( ‘whatever’, get_template_directory() . ‘/languages’ ); Given that … Read more

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