Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gettext for translation support and add french translation #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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