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

Add French translation #17

Open
bartoszlenar opened this issue Feb 24, 2021 · 0 comments
Open

Add French translation #17

bartoszlenar opened this issue Feb 24, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed translation Message translations

Comments

@bartoszlenar
Copy link
Owner

bartoszlenar commented Feb 24, 2021

Feature description

  • French translation for the default Validot's message set.
  • Placeholders support where applicable.
  • Fluent api extension method to ValidatorSettings so it can be nicely used from Validator.Factory.Create.

Feature in action

var validator = Validator.Factory.Create(
    specification,
    s => s.WithFrenchTranslation()
);

validator.Settings.Translations["French"] // this is the full translation dictionary

validator.Validate(model).ToString(translationName: "French") // gets result error output in French

Feature implementation walkthrough

  • In Validot, even English language is implemented as a translation that maps the property names from MessageKey class to the human-readable phrases.
  • Take a look at the files in src/Validot/Translations directory and see how the other languages are implemented.
  • In the project's root directory execute pwsh build.ps1 --target AddTranslation --translationName French
  • There is also build.sh if you don't have pwsh installed.
  • You'll notice a the new directory inside src/Validot/Translations that contains two files.
  • Open FrenchTranslation.cs and translate the English phrases.
  • Unit tests are in the related directory tests/Validot.Tests.Unit/Translations, but you don't need to do anything there.
    • Their role is to check whether the translation dictionary contains only the keys from the MessageKey class.
    • You don't need to include all keys translated, but if you want to skip something, please comment the line out instead of removing it (later it would be easier to check what's missing).
  • Done! Now you can make a PR! Thank you for your contribution!
@bartoszlenar bartoszlenar added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Feb 24, 2021
@bartoszlenar bartoszlenar self-assigned this Feb 24, 2021
@bartoszlenar bartoszlenar removed their assignment Mar 7, 2021
@bartoszlenar bartoszlenar added the translation Message translations label Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed translation Message translations
Projects
None yet
Development

No branches or pull requests

1 participant