Validot icon indicating copy to clipboard operation
Validot copied to clipboard

Add French translation

Open bartoszlenar opened this issue 3 years ago • 0 comments

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 avatar Feb 24 '21 21:02 bartoszlenar