How to reload wordpress textdomains at runtime
How to reload wordpress textdomains at runtime
How to reload wordpress textdomains at runtime
I guess you could use either HTML5 or IP based geolocation, set a current_language cookie and you are good to go. Or even better if you just simply ask the user about it. WordPress translation is not equal to multi-language by any means.
Logic of my function was all wrong, should have sorted the result in $trans_array before the foreach loop. Here is the updated code that worked, if anyone needs it: function rkm_translation_update() { global $wpdb; $trans_row = $wpdb->get_row(“SELECT * FROM id_item_lid”, OBJECT, 0); $id = $trans_row->id; $item = $trans_row->item_id; $lid = $trans_row->lid; $trans_array = $wpdb->get_results(“SELECT * … Read more
For the multilingual setup I´d recommend using WordPress Multisite. You can give each site it´s own top-level domain, or host them on subdomains or subdirectories. All sites in the network will share the same database (although they´ll have separate tables). To query the products you have a few options: Use switch_to_blog to query the other … Read more
WP translation functions, are meant to translate static strings. E.g. Regarding options, you should use them to translate the labels, not values. However, as far I remember, the translation utility of WPML works in contrast to standard translation, i.e. if you use that than you can’t load the transaltion using from .po/.mo files. If users … Read more
When a user creates a new page/post/product on one site, use the XML-RPC API to create a matching one on the other site. Make sure to save the ID of the original post under a meta key for the “duplicate” post, and then use the response ID from the API to save the “duplicate” ID … Read more
This is fixed. I made a small script to get this working. Because it was a multi language site I just named the site’s to the language they should be in. So the English page is named English, German page is called German etc. Made a small php script to check what the page name … Read more
I’m not completely sure whether this is what you want, but if the option page is in one language you can simply put the gettext call in the custom field itself to avoid using variables. For the admin you force the translation to spanish: function wpse227983_force_language ( $locale ) { if ( is_admin() ) { … Read more
Plugins and themes pull the translation files manually from (mostly) their directory. There are 2 different functions which handle this: For plugins : load_plugin_textdomain() For themes: load_theme_textdomain() The syntax would be something like this, mostly hooked into init or plugins_loaded action hook: load_plugin_textdomain( ‘text-domain’, get_template_directory() . ‘/some-directory’ ); OR: load_plugin_textdomain( ‘text-domain’, false, basename(dirname(__FILE__)).’/some-directory’); Look for … Read more
The third parameter to load_plugin_textdomain function should only be the plugin name suffixed with the language folder. It does not need the absolute path to the language folder. For e.g. in my scenario, the correct parameter is: load_plugin_textdomain( ‘bgm’, false, basename(__DIR__) . ‘/languages/’);