-
Notifications
You must be signed in to change notification settings - Fork 610
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
base: gh-pages
Are you sure you want to change the base?
i18n support #17243
Changes from 3 commits
fc6060b
75c0005
52da59e
61773e9
2b578f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,12 @@ var _ = function (input, o) { | |
item: _.ITEM, | ||
replace: _.REPLACE, | ||
tabSelect: false, | ||
listLabel: "Results List" | ||
listLabel: "Results List", | ||
tStatusResult: "${length} results found", | ||
tNoResults: "No results found", | ||
tStatusQueryTooShort: "Type ${minChars} or more characters for results.", | ||
tStatusStartTyping: "Begin typing for results.", | ||
tListItemText: "list item ${index} of ${length}" | ||
}, o); | ||
|
||
this.index = -1; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need a method for this instead of just raw For inspiration, check out how Mavo does this: https://github.com/mavoweb/mavo/blob/master/src/locale.js#L25 |
||
}); | ||
|
||
// Bind events | ||
|
@@ -259,7 +264,7 @@ _.prototype = { | |
if (i > -1 && lis.length > 0) { | ||
lis[i].setAttribute("aria-selected", "true"); | ||
|
||
this.status.textContent = lis[i].textContent + ", list item " + (i + 1) + " of " + lis.length; | ||
this.status.textContent = lis[i].textContent + ", "+ this.tListItemText.replace("${index}", (i + 1)).replace("${length}", lis.length); | ||
|
||
this.input.setAttribute("aria-activedescendant", this.ul.id + "_item_" + this.index); | ||
|
||
|
@@ -328,20 +333,20 @@ _.prototype = { | |
|
||
if (this.ul.children.length === 0) { | ||
|
||
this.status.textContent = "No results found"; | ||
this.status.textContent = this.tNoResults; | ||
|
||
this.close({ reason: "nomatches" }); | ||
|
||
} else { | ||
this.open(); | ||
|
||
this.status.textContent = this.ul.children.length + " results found"; | ||
this.status.textContent = this.tStatusResult.replace("${length}", this.ul.children.length); | ||
} | ||
} | ||
else { | ||
this.close({ reason: "nomatches" }); | ||
|
||
this.status.textContent = "No results found"; | ||
this.status.textContent = this.tNoResults; | ||
} | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
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:
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).