Skip to content

Conversation

@brenard
Copy link

@brenard brenard commented Dec 16, 2021

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.


which xgettext &>/dev/null || { echo "xgettext not found, please install it"; exit 1; }

cd "$( dirname "$0" )/../"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding -- to dirname and cd to support file names starting with "-" (rarely seen indeed):

cd -- "$( dirname -- "$0" )/../"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding -- to dirname and cd to support file names starting with "-" (rarely seen indeed):

cd -- "$( dirname -- "$0" )/../"

Good idea: done ! Thanks.

@brenard
Copy link
Author

brenard commented Jan 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants