• Hello,

    I have identified a critical bug in the localization logic (translation) within the file responsible for creating gift coupons (likely admin/class-store-credit-product-handling.php or similar).

    The issue prevents the email header translation (pi_sc_header) from being loaded correctly, resulting in outdated or mixed text being saved to the database, even when the translation files (.mo) are current.Problem Description

    In the createCoupon() function, when the sender ($from) is not empty, the PHP sprintf() function uses positional arguments (%1$s and %2$s) to format the email header string:

    PHP

    // Plugin Code:
    $header = sprintf(__('You got a gift coupon of %1$s from %2$s', 'store-credit-for-woocommerce'), wc_price($amount), esc_html($from));
    

    However, the corresponding entry (msgid) in the official plugin’s translation file (POT file) uses non-positional arguments (%s):

    Фрагмент кода

    // Incorrect String in .po/POT file:
    msgid "You got a gift coupon of %s from %s"
    

    This mismatch prevents translation systems like Poedit and Loco Translate from correctly mapping the translated string, leading to the use of an incorrect or fallback string.Proposed Change (for the POT file)

    To resolve this issue, the string ID (msgid) in the plugin’s POT file must be updated to match the positional arguments used in the PHP code.

    Please update the string:

    Фрагмент кода

    msgid "You got a gift coupon of %s from %s"
    

    to:

    Фрагмент кода

    msgid "You got a gift coupon of %1$s from %2$s"
    

    This change will ensure proper string mapping and enable all localized versions of the plugin to correctly handle the coupon metadata.

    Thank you for your time and attention to this issue.

Viewing 1 replies (of 1 total)
  • Hi,

    We have released a new version v1.0.49.76 upgrade to this new version in that we have created new translation file with these changes included in it

Viewing 1 replies (of 1 total)

The topic ‘Localization/Translation Bug in createCoupon() Function (Positional Argument Mis’ is closed to new replies.