My site is translated using Polylang and Hyyan WooCommerce Polylang Integration.
Everything is working in english and french. But
1) I can’t see any Stripe string to translate.
2) The card fields are always labelled in english.
3) The error messages are also in english.
Event though I saw the topic https://wordpress.org/support/topic/translate-card-errors/
Could you tell me how to customize WP/Woocommerce if needed?
Are you using the Stripe form or one of the custom forms? Each custom form has its strings available for translation using the recommended WordPress functions. Here is an example of a custom form:
The Stripe form automatically detects locale and provides placeholder translations:
I came back to the Stripe form: indeed the labels are now in French. But the error messages are still in english.
What error message are you referring to? Can you provide an example?
Some messages are generated client side and come directly from Stripe so they bypass the translations provided by the plugin.
@mrclayton For example
“The card number is invalid. Check the card details or use a different card.”
This seems to be a message from woocommerce/the plugin validation.
I also read about translating the messages coming from Stripe
That is a message that comes directly from Stripe and so is not translated by the plugin. I am investigating how to include these messages so they can be translated.
These strings will be included in the next release as part of the translatable options.
I totally forgot that I already added the ability to translate the Stripe client side error message. Here is the exact code:
The plugin follows all best practices for translations so you should see them in your translation plugin.
@mrclayton Thanks for the info.
1) I was not right saying the Stripe form is using the right language. Apparently it uses the browser language. Wich is different from the locale setting. For exemple even though I chose english setting for wordpress, and so the all page is in english, I see the labels in French.
2) How can I override wc_stripe_get_error_messages() to include both french and english support? I tried this in functions.php without success
add_action('woocommerce_checkout_process', 'wc_stripe_get_error_messages_translated'); remove_action( 'woocommerce_checkout_process', 'wc_stripe_get_error_messages' );
- This reply was modified 2 years, 8 months ago by mrguen.
ok. In my configuration I use Polylang. it has a feature “Strings translation”. I suppose that you are writting about it. Strings appear in this list depending on the plugins added. The support for Woocommerce translation by Polylang is done by Hyaan Woocommerce Polylang Integration plugin. All is working. But not the Stripe plugin strings. I don’t know where it the issue.
But I could go around this problem if I override the wc_stripe_get_error_messages() by testing the locale and returning the proper array of Strings, either in english or french. I suppose I could do it in functions.php, but I am not quite sure…
You might want to consult the documentation for your translation plugin. Perhaps you have to tell it when to import new strings for translation.
I have never had an issue with the Loco plugin that I recommended earlier.
The correct way to translate these strings is using the translations, not hooking in to a filter to provide the translations. I don’t recommend that you attempt to provide translations using a filter.
I asked Hyann Woocommerce Polylang Integration there opinion on this. Their reply is:
“This plugin by definition only supports the woocommerce plugin itself – it’s as much or possibly more than occasional community volunteers can support.
Other plugins including woocommerce extensions would need their own polylang layer.
You can add this for Stripe quite easily using the Polylang api ie:”
//register string for translation pll_register_string($name, $string, $group, $multiline); //return the text or translation pll__($variable) //echo the text or translation pll_e($variable)
So my understanding at this stage is that either
1) I modify your plugin to add pll_e($variable) everywhere. Not my cup of tea
2) I use a filter. Even though it might not work in future release of your plugin, I think it is the simplest and should only take some code in functions.php, but I don’t know much about it yet.
Have you got a better idea?
My understanding of Polylang is that it is used to translate dynamic content which is not necessary here. My plugin’s error messages are not dynamic and use the recommended WordPress translation functions. All you need to do is download Loco translate, pull the plugin’s translation file and you can start translating.
Take a look at the Stripe plugin’s POT file:
Loco translate will read that file and will make every string available for translation. Notice that all of the error message strings are in that POT file.
@mrclayton I have build a two language site on Polylang… Do you think I can use both Loco translate and Polylang at the same time?
@mrguen Yes you can use both since they both fulfill a different need. Polyland is for translating dynamic content which is content you can control such as page titles, menus, etc.
Loco translate is for translating static text generated by plugins.
@mrclayton Indeed I installed Loco translate and now editing the strings.
But There are lots of Strings and it is quite technical. I have seen this for inspiration https://www.micronator.org/affaires/produit/traduction-francaise-pour-woocommerce-stripe-gateway/ but the Strings don’t match completely with Stripe payment.
It is quite difficult to translate out of the context. For example “Charge” can be translated into “Montant”, “Débiter”, “Encaisser” etc depending on the context. Also it touches to legal matters.
I would be surprised that there wasn’t any already available PO et MO for French language… Do you know such a resource?
- The topic ‘Translation into french using Polylang’ is closed to new replies.