Localizing text from XML files

You should use a localized XML format like XLIFF or TMX , there is a tool to convert XLIFF to .po. If you cannot change the source XML you have a few options but it really depends how your outputting this XML info: Parse the XML ( for label) and create a .po with gettext … Read more

How to use is_rtl with my main style.css?

In your theme, you enqueue the stylesheet usually like this: add_action( ‘wp_enqueue_scripts’, ‘t5_enqueue_style’ ); function t5_enqueue_style() { wp_enqueue_style( ‘theme-name-default’, get_template_directory_uri() . ‘/css/default.min.css’ ); } The extra RTL stylesheet is enqueued here too, listing the default as dependency: if ( is_rtl() ) { wp_enqueue_style( ‘theme-name-rtl’, get_template_directory_uri() . ‘/css/rtl.min.css’, array ( ‘theme-name-default’ ) ); } So the … Read more

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

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

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

Text Domains Across Multiple Plugins & Themes

You don’t. Translations are part of each item’s commit history, they should be kept as separate as the PHP code. In terms of performance, you don’t win much with a combined text domain. Actually, you could lose performance, because if you need that one translation array almost everywhere, you cannot load it selectively anymore or … Read more

Change locale manually at runtime?

I’m trying to do a similiar thing, and the experts on the wp-hackers mailing list (Otto, Nacin) told me this: Don’t try to change WPLANG, you can’t change a define’d constant. Instead, change the global $locale, or put a filter on ‘locale’. So the best solution is to apply a filter on the ‘locale’ global … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduedusedueduedusedueduedusedus