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

Add lang attribute to translated text #7998

Merged
merged 11 commits into from
Sep 22, 2020
Merged

Add lang attribute to translated text #7998

merged 11 commits into from
Sep 22, 2020

Conversation

quincylvania
Copy link
Collaborator

@quincylvania quincylvania commented Sep 16, 2020

Closes #7963.

Turns out that adding a lang attribute to every text snippet in iD is a sweeping proposition 😬

This type of change isn't ideal, but I think it's necessary in making iD a first-class multilingual app. We can't really have mixed text throughout the UI without specifying what text is in what language. And some users of iD will always see mixed text unless we had a professional translation team that reaches 100% coverage in every language for every release (highly unlikely).

…ess `html: false` is specified in the options (re: #7963)

Update `text` functions to `html` to support inserting the `span` elements
Specify `html: false` for various instances where a `span` is not desired, e.g. `placeholder` and `title` attributes
@quincylvania quincylvania added the localization Adapting iD across languages, regions, and cultures label Sep 16, 2020
@quincylvania quincylvania marked this pull request as draft September 21, 2020 19:08
# Conflicts:
#	modules/ui/commit_warnings.js
#	modules/ui/field.js
#	modules/ui/fields/wikidata.js
#	modules/ui/fields/wikipedia.js
#	modules/ui/full_screen.js
#	modules/ui/panels/history.js
#	modules/ui/sections/entity_issues.js
#	modules/ui/sections/map_features.js
#	modules/ui/sections/raw_member_editor.js
#	modules/ui/sections/validation_rules.js
#	modules/ui/tag_reference.js
Add `t.html` function for getting the string with the `lang` attribute
Clean up a few things from prior commit
@quincylvania quincylvania self-assigned this Sep 22, 2020
@quincylvania quincylvania marked this pull request as ready for review September 22, 2020 16:44
@quincylvania quincylvania merged commit 8669967 into develop Sep 22, 2020
@quincylvania quincylvania deleted the lang-attributes branch September 22, 2020 17:40
@quincylvania
Copy link
Collaborator Author

I ended up making this backwards-compatible, so developers won't see different behavior from the t function. But now when we're displaying a translated string in the UI we should use the t.html function, which returns the text wrapped in a span element with the proper lang attribute. There's also a new coreLocalizer.tInfo function which returns both the text and locale, which is useful when you want to handle things manually.

Haven't yet achieved 100% coverage of the UI, but I'm happy with the groundwork so I went ahead and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
localization Adapting iD across languages, regions, and cultures
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support lang HTML attribute for multilingual text
1 participant