Support » Plugin: Payment Plugins for Stripe WooCommerce » Translation into french using Polylang

  • Resolved mrguen

    (@mrguen)


    Hello,

    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?

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    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:

    https://plugins.trac.wordpress.org/browser/woo-stripe-payment/tags/3.2.11/templates/cc-forms/bootstrap.php

    The Stripe form automatically detects locale and provides placeholder translations:

    https://stripe.com/docs/js/elements_object/create#stripe_elements-options-locale

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    Hello,

    I came back to the Stripe form: indeed the labels are now in French. But the error messages are still in english.

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    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.

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    @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

    https://stackoverflow.com/questions/23437439/non-english-texts-in-stripe-possible

    • This reply was modified 10 months, 1 week ago by mrguen.
    • This reply was modified 10 months, 1 week ago by mrguen.
    • This reply was modified 10 months, 1 week ago by mrguen.
    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    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.

    Kind Regards,

    Plugin Author Payment Plugins

    (@mrclayton)

    @mrguen,

    I totally forgot that I already added the ability to translate the Stripe client side error message. Here is the exact code:

    https://docs.paymentplugins.com/wc-stripe/api/source-function-wc_stripe_get_error_messages.html#1142

    The plugin follows all best practices for translations so you should see them in your translation plugin.

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    @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 10 months, 1 week ago by mrguen.
    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    You don’t need to add any code to support French. You just need to translate the already provided strings.

    Use something like Loco Translate so you can create your own translations.

    Kind Regards,

    Thread Starter mrguen

    (@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…

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    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.

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    Hi @mrclayton

    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?

    Plugin Author Payment Plugins

    (@mrclayton)

    Hi @mrguen,

    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:

    https://plugins.trac.wordpress.org/browser/woo-stripe-payment/tags/3.2.12/i18n/languages/woo-stripe-payment.pot

    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.

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    @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?

    Plugin Author Payment Plugins

    (@mrclayton)

    @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.

    Kind Regards,

    Thread Starter mrguen

    (@mrguen)

    @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?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Translation into french using Polylang’ is closed to new replies.