• Its possible to make your plugin compatible with Polylang?

    I thing will be a great addiction.

    Thanks

Viewing 1 replies (of 1 total)
  • jomo

    (@jonathanmoorebcsorg)

    I also use Polylang and would like this.

    Well I have one quick and not terribly nice solution for you, using localization files, which is quicker than changing all the code to add hooks to be able to use the Polylang String translation table.

    Unfortunately the localization only applies to the default values, and once any Save is made, the standard WC_Settings_Page is saving all the values, even if no change was made.

    We see when the values are read back out that the localized value is only applied if there is no saved value (and not even then for the main label, which is hidden if blank).
    ' value="' . get_option( 'alg_checkout_files_upload_label_upload_button_' . $i, __( 'Upload', 'checkout-files-upload-woocommerce' ) ) . '"' .

    So the quick cheat is to surround these with the __( function:

    				' value="'      . __( get_option( 'alg_checkout_files_upload_label_upload_button_' . $i, __( 'Upload', 'checkout-files-upload-woocommerce' ) ) , 'checkout-files-upload-woocommerce' ) . '"' .
    

    and create translation files using Loco Translate: note these need to go in the \language\plugins directory, not the loco directory, as there needs to be a base version.

    This only works if you do not change the strings in the settings page, only change the strings in the translation files.

    For a full Polylang implementation, use pll_register_string to register all the strings,
    then you can replace this hack with pll__() functions

Viewing 1 replies (of 1 total)
  • The topic ‘Polylang strings for translation’ is closed to new replies.