Thread Starter
unicco
(@unicco)
Am I forced to implement translate_text(), parsing my fields 2-char languagecode, on all strings?
Isn’t there a smarter way to do this?
Thread Starter
unicco
(@unicco)
Yeah, I’ve looked at these sites 🙂
I havn’t really found a good solution for this yet, course – as I explain – I’d like to control the invoices generated language at the orders details. Could be nice, if there was a smarter way than using the:
$text = apply_filters(‘translate_text’, $text, $lang=null, $flags=0);
$term = apply_filters(‘translate_term’, $term, $lang=null, $taxonomy=null);
$url = apply_filters(‘translate_url’, $url, $lang=null);
Course as I see it, I’ve to apply this on all strings, in order to change to language accordingly to my fields languagecode.
Thread Starter
unicco
(@unicco)
All strings is using the __, so wordpress knows it has to translate them. But I’m not sure where I can configure/change which language they actually should translate into. Could be nice if there was some global variable I could assign, or something. Dunno if it makes sense?
Have you tried to assign global variable $q_config['language']='xx'? I am not sure if it is going to work, and you probably wish to switch it back to what it was after you are done.
You have to declare it with global $q_config;, as you probably already guessed.
Thread Starter
unicco
(@unicco)
Thanks, I’ll try this tomorrow. I’ll let you know how it works.
Thread Starter
unicco
(@unicco)
Hi again,
I’ve tested this, and it seems to work perfectly, thanks Clause!:
global $q_config;
if (get_post_meta($order->id, 'lang_code', true) != '') {
$q_config['language'] = get_post_meta($order->id, 'lang_code', true);
}
generates the invoice in the language I’ve specified.