i18n support#17243
Conversation
LeaVerou
left a comment
There was a problem hiding this comment.
Hey, thanks for working on this! I left some comments.
| tNoResults: "No results found", | ||
| tStatusQueryTooShort: "Type ${minChars} or more characters for results.", | ||
| tStatusStartTyping: "Begin typing for results.", | ||
| tListItemText: "list item ${index} of ${length}" |
There was a problem hiding this comment.
I think these should be in a separate object, not just as raw properties. Also, we do not need them on every instance, what we need is a way to select a language for the instance. So I'd suggest a data structure like:
Awesomplete.languages = {
"en-us": {
"list-label": "Results List"
}
}Then instances would point to one of these objects either by storing the language, or a reference to the object (I'll leave that up to you).
| "aria-atomic": true, | ||
| inside: this.container, | ||
| textContent: this.minChars != 0 ? ("Type " + this.minChars + " or more characters for results.") : "Begin typing for results." | ||
| textContent: this.minChars != 0 ? this.tStatusQueryTooShort.replace("${minChars}", this.minChars) : this.tStatusStartTyping |
There was a problem hiding this comment.
We probably need a method for this instead of just raw .replace() calls (also note that if the phrase needs to continue the substitution multiple times, this will only substitute the first one).
For inspiration, check out how Mavo does this: https://github.com/mavoweb/mavo/blob/master/src/locale.js#L25
|
Hello @LeaVerou |
#17242
I tried to add simple i18n support. is currently running as part of our timetable: https://preview-timetable.dsiag.ch
Cheers, Roman