Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n support #17243

Open
wants to merge 5 commits into
base: gh-pages
Choose a base branch
from
Open

i18n support #17243

wants to merge 5 commits into from

Conversation

bertolami
Copy link

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

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

awesomplete.js Outdated
@@ -62,7 +67,7 @@ var _ = function (input, o) {
"aria-live": "assertive",
"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
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
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