vt-middleware / passay

Password policy enforcement for Java.
http://www.passay.org
Other
275 stars 63 forks source link

Support multi language for passay.properties #115

Closed ansidev closed 4 years ago

dfish3r commented 4 years ago

Support for resource bundles was added in this commit: https://github.com/vt-middleware/passay/commit/51eeabbd7a2de0f370be020218617491c646b8e9

Please try out the latest snapshot and let us know if that meets your requirements.

ansidev commented 4 years ago

I mean that there is only one English translation for passay.properties at this time. I want to have many passay.properties so the developer can load based on locale.

For example: Currently, if I want the message is in German, I must translate it manually, then add config to load the German translation manually.

dfish3r commented 4 years ago

We'd certainly welcome those sorts of contributions. We don't have the expertise to provide additional translations.

ansidev commented 4 years ago

@dfish3r Of course, but at this time the library always loads passay.properties. You should support dynamic loading the properties file by language code. Then the community will make contributions for the language files.

dfish3r commented 4 years ago

So the way to accomplish that is: Create a properties file called passay_de.properties and put it on your classpath. Then

ResourceBundleMessageResolver resolver = new ResourceBundleMessageResolver(
  ResourceBundle.getBundle("passay", Locale.GERMAN));
PasswordValidator validator = new PasswordValidator(resolver, rule1, rule2, ...);

Using the default locale should load language specific properties if they exist, otherwise it will fallback to the english default.

ansidev commented 4 years ago

Yes, I know. I have read your documentation. But with the current implementation:

If the project is using English only, it does not the problem.

If your library support this locale files by default, it 's better. We just load the passay file with the input locale.

dfish3r commented 4 years ago

Sure. If/when someone contributes a language specific file we'll include it in the jar. Until then, you have to solve the problem of distributing a custom properties file.

ansidev commented 4 years ago

I think the first step is support loading the passay_{languageCode}.properties. After that, we will update the translation for each language.

It will make the contribution easier.

dfish3r commented 4 years ago

Please send me a PR for the changes you're thinking about. I think code review is the best way to continue this discussion.

dfish3r commented 4 years ago

Pushed a commit related to this: https://github.com/vt-middleware/passay/commit/5587010e4da27c6f794bff3660fab49069052623

dfish3r commented 4 years ago

No feedback from reporter. Feel free to reopen this for further discussion.