• I have translated the plugin using Loco Translator, everything works fine except for this string which won’t translate: Are you over %s years of age?

    I have tried changing it under Messages as well, I believe the plugin pulls the string from within messages tab, and not the age-gate.pot file.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Phil

    (@philsbury)

    Hi @lennilg,

    Yes it pulls from the messages settings, but also sends it through the localisation settings. If it is exactly ‘Are you over %s years of age?’ the pot should still pick it up.

    That’s a bit legacy though and probably going to change in a future release to just pick up from the settings.

    Thanks
    Phil

    Thread Starter lennilg

    (@lennilg)

    Strange, it won’t pull the translation from the pot file, if I remove the string under the messages tab, the modal has no text, only yes / no.

    Plugin Author Phil

    (@philsbury)

    Hi @lennilg,

    Yeah that would be expected, if you remove it nothing will be passed through. Essentially, you would be doing __('', 'age-gate'). It doesn’t fall back if nothing is set. If you set the message input to match the string in the pot, does it work?

    It’s only really in the pot file for translating during install as all the user settings will override it after that.

    Thanks
    Phil

    Thread Starter lennilg

    (@lennilg)

    I see, it still seems like the “Are you over %s years of age?” string is the only one that does not default to the pot file if it is unset, or set. If I remove the text at Yes or No fields in the messages tab, the plugin pulls it from the POT file and if I change language on my website, it translates into supported languages such as Italian, German and any other language that users have previous translated and uploaded to WordPress.com

    In general, it’s best practice to rely on the POT files as fallback, rendering webmasters capable of removing the manually typed strings, and translating the plugin in to any and all language.

    I did notice, that the line numbers in the POT file, does not match those of class-age-gate-activator.php

    Plugin Author Phil

    (@philsbury)

    Hi @lennilg,

    The pot probably needs a bit of an update. I’m working on a big redevelopment of the plugin at the moment so will sort some of these issues there – any thoughts are welcome!

    The thinking behind not falling back here is it’s potentially confusing for users. Yes/No as an example always need some kind of text whereas that message doesn’t. So if an admin removes that text, they’d expect it to be removed from the front end rather than default to “Are you over %s years of age?”. (if the field is blank, it removes the element). Many who are just installing plugins won’t have the knowledge of pot files, or even PHP in some cases so it’s finding a balance.

    If it’s a blocker for you I can have a think about how to best address it in a patch. 🙂

    Cheers
    Phil

    Thread Starter lennilg

    (@lennilg)

    That makes sense, I’d expect a checkbox that will state, leave blank, once checked, the input field is grey and the plugin ignores the localized string and defaults to blank instead.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Are you over %s years of age? Localize not working.’ is closed to new replies.