Skip to content

i18n support#17243

Open
bertolami wants to merge 5 commits into
LeaVerou:gh-pagesfrom
dsi-engineering-ag:main
Open

i18n support#17243
bertolami wants to merge 5 commits into
LeaVerou:gh-pagesfrom
dsi-engineering-ag:main

Conversation

@bertolami
Copy link
Copy Markdown

#17242

I tried to add simple i18n support. is currently running as part of our timetable: https://preview-timetable.dsiag.ch

Cheers, Roman

Copy link
Copy Markdown
Owner

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for working on this! I left some comments.

Comment thread awesomplete.js
tNoResults: "No results found",
tStatusQueryTooShort: "Type ${minChars} or more characters for results.",
tStatusStartTyping: "Begin typing for results.",
tListItemText: "list item ${index} of ${length}"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread awesomplete.js Outdated
"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
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bertolami
Copy link
Copy Markdown
Author

Hello @LeaVerou
Could you please check again. I added a static field with translations and a field with the language. If it makes sense to you now, I would update the doc.
Cheers, Roman

@bertolami bertolami requested a review from LeaVerou August 16, 2021 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants