Interface translation without plugins
Interface translation without plugins
Interface translation without plugins
Update setlocale(LC_TIME, “th_TH.UTF-8”); echo strftime(“%A %d %B %Y”, strtotime(get_the_date())); Before: อาทิตย์ 03 มกราคม 2016 //$strdate = get_thai_date(); //print_r($strdate[“number”]); //preg, strstr or others. //$strdate = date_i18n(…); After: อาทิตย์ ๐๓ มกราคม ๒๐๑๖
How to deal with differently translated prepositions?
Already found out: load_textdomain(‘my-text-domain’, TEMPLATEPATH . ‘/languages/’. $my_locale . ‘.mo’); In some cases it could be useful to restore the previous text domain, so we should make a backup. An old function I had hidden in my code that does all, is this one: function __2($string, $textdomain, $locale){ global $l10n; if(isset($l10n[$textdomain])) $backup = $l10n[$textdomain]; load_textdomain($textdomain, … Read more
post_title_ml property should be used to get a raw post value, instead of post_title $title = $post->post_title_ml To translate raw value translate_text filter can be used $english_title = apply_filters(‘translate_text’, $title, ‘en’); Or qtranxf_use_language() function $english_title = qtranxf_use_language(‘en’, $title, false, true);
Translate wordpress without duplicate custom post
Because the translate function __() worked fine, I suspected printf() was the culprit. Turns out sprintf() is what I needed! printf() arguments work differently
get_locale() and get_user_locale() are functions to retrieve the locale that is already set. To change it, you want to “filter” the locale value. For that, you want to use the locale filter hook. The following should do it: add_filter( ‘locale’, ‘custom_locale’ ); function custom_locale( $locale ) { $locale = ( is_admin() ) ? “en_US” : … Read more
Ok, found on a blog this solution, paste in functions.php of your child theme : function child_theme_slug_setup() { load_child_theme_textdomain( ‘parent-theme-domain’, get_stylesheet_directory() . ‘/languages’ ); } add_action( ‘after_setup_theme’, ‘child_theme_slug_setup’ );
I’d recommend you using Loco Translate plugin to create a translation. If you are creating a theme, you should specify the Text Domain and Domain Path in your style.css file. /* Theme Name: My Theme Name Author: My Name Author URI: http://sample.url Description: Your theme description Version: 1.0.0 Text Domain: mydomain Domain Path: /lang */ … Read more