Validot
Validot copied to clipboard
Add Japanese translation
Feature description
- Japanese translation for the default Validot's message set.
- Placeholders support where applicable.
- Fluent api extension method to
ValidatorSettings
so it can be nicely used fromValidator.Factory.Create
.
Feature in action
var validator = Validator.Factory.Create(
specification,
s => s.WithJapaneseTranslation()
);
validator.Settings.Translations["Japanese"] // this is the full translation dictionary
validator.Validate(model).ToString(translationName: "Japanese") // gets result error output in Japanese
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 Japanese
- 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
JapaneseTranslation.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).
- 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!