Support » Plugin: Two Factor Authentication » Bad strings i18n

  • Resolved Pedro Mendonça


    Hi @davidanderson,

    This coded string is a hardcoded concatenation that don’t allow a good translation in languages where the concatenation would need to work differently.

    <?php _e('You are currently using', 'two-factor-authentication'); ?> <?php print strtoupper($algorithm_type).', '.($algorithm_type == 'totp' ? __('a time based', 'two-factor-authentication') : __('an event based', 'two-factor-authentication')); ?> <?php _e('algorithm', 'two-factor-authentication'); ?>.

    The current concatenation:
    “You are currently using” + ” ” + algorithm_type + “, ” + [“a time based”|”an event based”] + “algoritm” + “.”

    It could be changed to 3 strings:
    “You are currently using %s, %s.” – %s being [“a time based algorithm”|”an event based algorithm”].

    But given the complexity of the string and the confusion of the second half of it, probably the best solution would be no concatenation at all, and no variables, just two very similar simple strings:
    – “You are currently using TOTP, a time based algorithm.”
    – “You are currently using HOTP, an event based algorithm”.

    This would reduce the complexity and a total of 4 translations strings to 2 with perfect i18n.


    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Another issue I’ve spotted is the “Two Factor Authentication” translation string. You should add a context to all ocurrences, to allow its translation in several places like menus and page titles, while the single string related with the plugin name could be left untranslated.

    Plugin Author David Anderson


    Thank you! Yes, that concatenation is terrible. I have fixed it for the next release.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bad strings i18n’ is closed to new replies.