Approach for Internationalizing Schema Error Messages in Effect Typescript Library
What's the recommended approach to i18n of schema errors?
translating
manually adding
In this section of the docs, we start seeing some error "code" as "message": https://effect.website/docs/schema/error-messages/#compound-schemas
this however lacks the configured length of e.g
if you inspect the annotations, you could use the json schema annotations to extract the number
If you can somehow gather this data together, you can easily make translations or make programatic decisions:
translating
a string at most ${maxLength} character(s) long is complicated, would need to parse the message.manually adding
message annotations is tedious and doesn't really scale.In this section of the docs, we start seeing some error "code" as "message": https://effect.website/docs/schema/error-messages/#compound-schemas
"error_max_length_field"this however lacks the configured length of e.g
1.if you inspect the annotations, you could use the json schema annotations to extract the number
1. (I haven't tried this in practice yet)If you can somehow gather this data together, you can easily make translations or make programatic decisions:
Effect Documentation
Customize and enhance error messages for schema decoding with default, refined, and custom messages.
