Validot
Validot copied to clipboard
Add French translation
Feature description
- French translation for the default Validot's message set.
- Placeholders support where applicable.
- Fluent api extension method to
ValidatorSettingsso it can be nicely used fromValidator.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
MessageKeyclass 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.shif you don't have pwsh installed. - You'll notice a the new directory inside src/Validot/Translations that contains two files.
- Open
FrenchTranslation.csand 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
MessageKeyclass. - 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).
- Their role is to check whether the translation dictionary contains only the keys from the
- Done! Now you can make a PR! Thank you for your contribution!