Translate
-
Hi! Great plugin, but I have one issue with it. I cannot seem to translate the “Buy now button” into my language. I tried using the loco plugin to do this but that did not work. Is it possible to translate this for me? I have the free version.
The page I need help with: [log in to see the link]
-
Hi @syntve, I will check and let you know.
Hi @syntve
Use below snippet and then toy should be able to translate
// Code Snippet for Addto Cart or Buy Now button Text
add_filter( 'wpowp_translate_add_cart_txt', 'wpowp_translate_add_cart_txt' ); function wpowp_translate_add_cart_txt( $add_cart_text ){ return __('Buy Now','wpowp'); }
NOTE: you can add this snippet in theme functions.php or use a plugin to add php snippets.
Thanks in advance-
This reply was modified 1 year, 8 months ago by
tobifjellner (Tor-Bjorn “Tobi” Fjellner). Reason: Moved the snippet into a code block, this way the straight quotes will (hopefully) not be converted to smart quotes and mess stuff up
Hi, I had the same problem – need to translate in WMPL. I added your code to functions.php and got this error:
syntax error, unexpected identifier “Now’”, expecting “)”
Can you please provide the correct snippet? Thank you so much.Thank you, that works in functions.php. But now whre do I make it translatable in WMPL? I don’t see it in String translations, or the Translator of the Page…Can you pls provide more instructions?
@ndy23
Oh. Now we’re reaching into interesting territory.
In the translation call
__('Buy Now','wpowp')
The “wpowp” parameter is the text-domain. So you’d need to create a translation file template wpowt.pot and then translate it into, wpowt-sv_SE.po and compile wpowt-sv_SE.mo, and finally make sure to load this translation domain in the right place…In this case, it would probably be easier for you to change that parameter to the text-domain of your theme and then use your translation software to scan for strings that need to be translated.
An elegant solution would be to package this snippet into your own little custom plugin, and then with correct header declarations you could convince WordPress to automatically load the text-domain of your custom plugin. You can try and find more details at https://developer.wordpress.org/plugins/internationalization/EditAdd: the sample file names I showed was for Swedish, in case you wonder.
-
This reply was modified 1 year, 8 months ago by
tobifjellner (Tor-Bjorn “Tobi” Fjellner).
Hi, so definitely over my skills. Would this translate only the BUY NOW, right? What if we have to translate your whole plugin in WMPL?
All the rest of the plugin can be translated via https://translate.wordpress.org/projects/wp-plugins/wc-place-order-without-payment/
You can read more about how we work with translations of User Interface at https://make.wordpress.org/polyglots/handbook/
Note that there are differences between various language teams, how exactly they operate.
But WPML will just make sure to load the UI translations for the correct language every time. (If there is a translation available.) In addition, I believe it also offers you the possibility to locally translate UI elements that aren’t translated from our global translation repository.@ndy23 @tobifjellner updated plugin to load text domain in release 2.5.3
Do I still need to add the snippet for it to work? I now found the Buy now in the Loco translator plugin, but when I translate it nothing happens. It still says “Buy Now” even if I have translated it to Norwegian. I can easily translate the other text of your plugin to Norwegian in Loco and it changes immidiateley but not Buy Now. It is like it is locked.
I have also made a suggesion to https://translate.wordpress.org/projects/wp-plugins/wc-place-order-without-payment/stable/nb/default/?filters%5Bstatus%5D=waitingIt’s not possible to translate Buy Now with Loco in other language. Can you fix this problem?
Hi @evilmc, I will check and fix this
Hi @evilmc Loco Translate does not translate dynamic content, but if you still want to Translate Buttons please use default plugin inputs i.e dont edit any button texts and then the text can be translated via Loco Translate.
If you still have any questions please create a support ticket on Support Desk
Thanks in advance -
This reply was modified 1 year, 8 months ago by
- The topic ‘Translate’ is closed to new replies.