zxcvbn-php icon indicating copy to clipboard operation
zxcvbn-php copied to clipboard

Use gettext for translation support and add french translation

Open brenard opened this issue 3 years ago • 1 comments

Hello,

I'm currently working on French support and this second PR add gettext usage to allow warning and suggestion messages translation. My modifications:

  • use dgettext() to translate warning and suggestion messages from custom text domain ZxcvbnPhp. Note: TimeEstimator::displayTime() method was simplified using dngettext() that handle plural forms.
  • Add Locales directory to store translation stuff
  • Bind ZxcvbnPhp text domain to Locales directory in Zxcvbn class constructor
  • Add extract_messages.sh script that handle messages extractions using xgettext and generate/update Locales/zxcvbn-php.pot file
  • Add french translation in Locales/fr_FR.UTF8 directory

This solution permit to easily integrate this library in PHP application that already use gettext for translation. Other applications just have to set locale by setting LANGUAGE environment variable or using setlocale() function.

brenard avatar Dec 16 '21 17:12 brenard

Hello, I rebased my commits on your master branch. I still hope this PR could be merge upstream :)

brenard avatar Jan 26 '23 14:01 brenard