ember-intl support for ember-changeset-validations messages
Adds support for ember-intl to ember-changeset-validations.


``sh`
ember install ember-intl-changeset-validations
Then you have to call the registerIntlChangesetValidationMessages function:
`js
import { registerIntlChangesetValidationMessages } from 'ember-intl-changeset-validations';
export default class ApplicationRoute extends Route {
@service intl;
beforeModel() {
this.intl.setLocale(['cs-cz']); // You have to setLocale() first
registerIntlChangesetValidationMessages(this.intl);
}
}
`
In your project create a file with translations:
`json`
// /translations/validations/cs-cz.json
{
"validations": {
"inclusion": "Musí být vybráno",
"present": "Prosím vyplňte",
"between": "Musí mít mezi {min} a {max} znaky",
"invalid": "Neplatný formát",
"email": "Nplatná e-mailová adresa"
}
}
- Example is for the cs-cz locale.validations
- All validation messages have to be nested under key.
- Make sure to check the list of all the possible default validation messages.
From now on all the validation messages from ember-changeset-validation should be translated.
You can see it in action in the test-app:
- /test-app/translations/validations/cs-cz.json
- /test-app/app/routes/application.js
- /test-app/app/templates/application.hbs
- Currently when you _change_ the locale (using setLocale) _after_ it has been set for the first time, then ember-intl-changeset-validations will not change the translation.
- Ember.js v3.28 or above
- Ember CLI v3.28 or above
- Node.js v18 or above
- ember-intl >= v7.x
- Big thanks to ember-i18n-changeset-validations that showed me 90% of the how-to needed to make this work.
- Kudos to Isaac Lee for answering questions about ember-intl`.
This project is licensed under the MIT License.