-
Notifications
You must be signed in to change notification settings - Fork 240
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
Refactor i18n and add additional translation keys #479
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I couldn't get nested keys to work with jquery-i18next. It also lets us use a data-i18n-opts attribute for key interpolation.
I didn't link directly to the file for long-term URL stability
6282bf0
to
e585763
Compare
to know if we should i18nize the text or not
again to know if we should i18nize the default caption or not
schloerke
approved these changes
Jan 29, 2021
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.
LGTM given small code shuffle / notes
Thanks @schloerke! I've updated the comments and shuffled the code as requested 😄 |
Makes it harder to forget the `button.` prefix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've refactored the internationalization scripts to remove the jquery-i18next dependency in favor of a hand-rolled function that achieves similar results, but lets us store some of the i18n parameters in
data-i18n-
HTML element attributes.I also plan to refactor the
i18n_translations()
function to use a better format and preparation process that will be more robust for Unicode characters not in UTF-8.The big change here is that localization will now:
data-i18n
attribute of the HTML element to look up the translationdata-i18n-attr-<name>
attribute to look up the translation for the<name>
attribute.data-i18n-attr-title = "button.runcodetitle"
uses thebutton.runcodetitle
key to set thetitle
attribute of the current element.data-i18n
attribute for internationalization to occur, if the innerHTML is not to be set, then setdata-i18n = ""
.i18next.t()
method can be stored in thedata-i18n-opts
attribute. This is particularly useful for passing{count: collection.length}
for pluralization.I added an R function helper
i18n_span()
to help set the above attributes from the R side. For buttons created in JavaScript, these attributes are added as/where needed.PR task list:
devtools::document()
Fixes #476