Edit: could be very useful in upcoming immigrant safety forms.
A few more details on what's holding up this PR:
-
translating without making the user add alMonthLabel: ${ word('Month') } each time. This fix will have to be upstream, but my suggestion is to add a feature to CustomDataTypes. Right now, custom datatypes have an attribute, mako_parameters, like this:
mako_parameters = [
...
"alMonthLabel",
"alDayLabel",
"alYearLabel",
]
We should add another attribute, something like default_mako_parameters, which would look like:
default_mako_parameters = {
"alMonthLabel": "${ word('Month') }"
...
}
i.e. a dictionary from the parameter to a python expression as a string that will be evaluated during the interview if the author doesn't give a value for the param. Doing this should be backwards compatible with how we do it now, if we release and folks start using these params. This feature would just extend it for folks who don't use it yet.
-
translating other ui and error messages. These include:
- other values from our custom data type (min validation, 'birthdate must be in the past', too many days, etc.). To translate these, we would have to one param for each, and use the same solution as above to translate them. Would work, much more cumbersome than 3 different strings, but I can't think of a better solution.
- strings from the phone validation library (https://github.com/jackocnr/intl-tel-input/blob/2060adc877532f41dc53d4563ce970abbc6a6047/src/js/intl-tel-input/i18n/en/index.ts#L4-L10). To translate these, we would have to pass the language code (could probably also get it from
<html lang="...">) to where we initialize the library (here, using i18n: https://intl-tel-input.com/docs/options.html#i18n), and make sure the languages we use are contributed upstream.
My priorities are still elsewhere, so I can't spend too much time on this, but we can discuss at the next deep dive, and if this plan sounds good, we can merge this PR.
Originally posted by @BryceStevenWilley in #317 (comment)
Edit: could be very useful in upcoming immigrant safety forms.
A few more details on what's holding up this PR:
translating without making the user add
alMonthLabel: ${ word('Month') }each time. This fix will have to be upstream, but my suggestion is to add a feature to CustomDataTypes. Right now, custom datatypes have an attribute,mako_parameters, like this:We should add another attribute, something like
default_mako_parameters, which would look like:i.e. a dictionary from the parameter to a python expression as a string that will be evaluated during the interview if the author doesn't give a value for the param. Doing this should be backwards compatible with how we do it now, if we release and folks start using these params. This feature would just extend it for folks who don't use it yet.
translating other ui and error messages. These include:
<html lang="...">) to where we initialize the library (here, usingi18n: https://intl-tel-input.com/docs/options.html#i18n), and make sure the languages we use are contributed upstream.My priorities are still elsewhere, so I can't spend too much time on this, but we can discuss at the next deep dive, and if this plan sounds good, we can merge this PR.
Originally posted by @BryceStevenWilley in #317 (comment)