-
Notifications
You must be signed in to change notification settings - Fork 162
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 members for localization #1101
Conversation
I'd prefer adding the "_localized" suffix across the board as it makes it explicit what the member's purpose is. |
Yeah, I guess it does make sense to make it "_localized" as this can only be used for that. |
From editors meeting:
TPAC discussion here |
Instead of defining new members, let's instead define |
We already have defined localizable members so we can already reuse that. |
Here is what an shortcuts member might look like with some _localized members sprinkled in: {
"shortcuts": [
{
"name": "Play Later",
"name_localized": {
"fr": "Écouter plus tard"
},
"description": "View the list of podcasts you saved for later",
"description_localized": {
"fr": { "lang": "en", "dir": "ltr", "value": "English description because that's part of our brand." },
},
"url": "/play-later",
"icons": [
{
"src": "/icons/play-later.svg",
"type": "image/svg+xml"
}
],
"icons_localized": {
"fr": [
{
"src": "/icons/fr/play-later.svg",
"type": "image/svg+xml"
}
]
}
},
{
"name": "Subscriptions",
"description": "View the list of podcasts you listen to",
"description_localized": {
"fr": "Consultez la liste des podcasts que vous écoutez."
},
"url": "/subscriptions?sort=desc"
}
]
} Note: updated to include a triple example. |
Question is if we should allow localizing various URLs... that gets a bit messy in places, but could be doable. |
@marcoscaceres @dmurph Thanks. Let's also localize |
LTTP... thanks for working on this Christian!
Wait, why are we localizing URLs? That seems undesirable to me. It means that shortcuts can go to different places depending on the language, and we need to update functionality that may be cached (that isn't just string/icon data). This may add non-trivial implementation complexity (it would require a deeper analysis to understand to what degree). Would the use case for this be that you can have URLs with different |
Maybe we can also loop in @aphillips to see whether it makes sense to localize URLs. |
Icons, graphics, or remote content (help pages, for example) are sometimes varied by locale or by region (with locale serving as a poor proxy for region). This might be done, for example, because the icon contains some text or because a graphic shows a culturally-linked image (personal images, national costume, post box shapes, etc. etc.) that the user wishes to localize. Or it might be because functionality or defaults differ (sorting based on pronunciation instead of name for Chinese, for example) We don't know why the user might want to localize the icon or shortcut (or whatever). I agree that this can be abused and there might be reasons not to allow some fields to be localized, although I'd probably thinks about health warnings first? |
Probably the most elegant, but it’s not within the realm of possibility for a lot of orgs and site types (thinking static sites, for example).
See also MDN style links where the language code is embedded in the URL path.
Agree on all of these. |
Just one data point, but as a past precedent the similar Web of Things (WoT) Thing Description specification landed on I personally don't like that solution because I prefer using HTTP content negotiation with an If consistency between W3C specifications is considered important, then I note that in HTML the Example: {
"lang": "en",
"dir": "ltr",
"name": "Super Racer 3000",
"names": {
"fr-FR": "Super Coureur 3000",
"es-ES": "Súper Corredor 3000"
},
"short_name": "Racer3K",
"short_names": {
"fr-FR": "Coureur3K",
"es-ES": "Corredor3K"
},
"icons": [
{
"src": "icon.png",
"sizes": "64x64",
"type": "image/png"
},
{
"src": "icon-fr.png",
"sizes": "64x64",
"type": "image/png",
"lang": "fr-FR"
},
{
"src": "icon-es.png",
"sizes": "64x64",
"type": "image/png",
"lang": "es-ES"
}
],
"scope": "/",
"id": "superracer",
"start_url": "/start.html",
"display": "fullscreen",
"orientation": "landscape",
"theme_color": "aliceblue",
"background_color": "red"
} Note that One question: How does Hope this helps. |
Perhaps we should clarify what "localize URLs" means. Are we talking about:
I think we generally agree that we need to localize icons, but we're doing that at the Maybe it makes sense for URLs like shortcuts to be able to change based on language, but really the point of this initiative (I thought) was to be able to localize your app's metadata that gets displayed at the OS level, like name and icon, not to solve the problem of localizing all the content in the app. (If you can't configure your server to serve content based on headers, you can still make your service worker return localized content based on Accept-Language.) An app that relies purely on the manifest URLs to display content in the user's language is likely to be quite brittle. I think we could run into major headaches if we allow I prefer if we just start with
This was discussed at TPAC (search for "dir") - unfortunately when I asked this question, the answer was not recorded ("?"). From memory, @aphillips pointed out that we may not know the language's direction because languages are not set in stone. I think the overwhelmingly common case will be a known language, which means we should be able to derive |
Supportive of what @mgiuca said above... let's start small and go from there (and definitely let's not have multiple ways of doing the same thing, specially with URLs). And yes, let's keep the localizable members restricted to a small set (including image objects, not members within those objects). |
@mgiuca noted:
Your specification should not derive direction from language unless there is no other alternative. This is not because languages are mutuable. You may permit an item that lacks separate direction metadata to attempt to use the language to estimate the direction or to act as a hint, but this should not be the default way of doing it. In fact, I18N recommends making the direction We have extensive guidance in https://www.w3.org/TR/string-meta/ and we're working on an update to our guidance about manifests here (I hope to land this PR on Thursday) which you may find useful here. |
Manifest Working session notes: This seems to be the concluded format (copied from Marcos's comment above) with triple examples: {
...
"dir": "ltr",
"lang": "en-x-marcos",
...
"shortcuts": [
{
"name": "Play Later",
"name_localized": {
"fr": "Écouter plus tard"
},
"description": "View the list of podcasts you saved for later",
"description_localized": {
"en": { "value": "My App, hey!", "dir": "ltr", "lang": "fr"},
"en-GB": { "value": "My App, eh wut?", "dir": "ltr"},
"fr": "string",
"ar": { "value": "...", "dir": "rtl" }
},
"url": "/play-later",
"icons": [
{
"src": "/icons/play-later.svg",
"type": "image/svg+xml"
}
],
"icons_localized": {
"fr": [
{
"src": "/icons/fr/play-later.svg",
"type": "image/svg+xml"
}
]
}
},
{
"name": "Subscriptions",
"description": "View the list of podcasts you listen to",
"description_localized": {
"fr": "Consultez la liste des podcasts que vous écoutez."
},
"url": "/subscriptions?sort=desc"
}
],
...
}
TPAC notes from this are here |
I suppose the stray "en": { "value": "My App, hey!", "dir": "ltr", "lang": "fr"}, I could edit your comment directly, but wanted to make sure it's indeed a copy/paste first. |
This actually is intended - the example might not be great, but we need the ability for a string to be displayed in a different language A when showing for language B. For example, if a product name or logo etc was a character in a different language, the dev can make sure it renders in the desired language for the user's chosen display language. |
@christianliebel can you check #676 ... and update the description of this issue as closing that bug, as well as any other bugs this will close? |
This is now picked up in w3c/manifest#1101.
hello, everyone I would suggest that localization be a native feature for all strings. Hence we don't need extra fields for localization. just to enhance the parser to parse new strings. My suggestion is that strings can divided into two types:
lang: "en", // fallback language if browser meets no locale strings listed
"name": {
"en": "Web App", // fallback for all en-* browsers or for general en-* users
"en-US": "Web App", // specific string for localized en
"zh": "网站应用”, // fallback for all zh-* browsers or for general zh-* users
"zh-CN": "网站应用”, // specific string for localized zh
...
} |
@@ -2298,7 +2556,9 @@ <h3> | |||
</h3> | |||
<p> | |||
The <dfn>application's name</dfn> is derived from either the | |||
[=manifest/name=] member or [=manifest/short_name=] member. | |||
[=manifest/name=] member or [=manifest/short_name=] member. The user |
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.
This needs more clarification as to which one wins.
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.
In Chromium we use them depending on UX needs. It's not implemented, but I would like to follow similar rules for extensions - short_name
is truncated to 12 characters and name
is truncated to 75.
This sets expectations for devs, and allows the user agent to show an app name where there might not be much space.
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.
Could we discuss that in a separate issue? It used to be like this and is not directly related to l10n.
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.
How they are treated by the OS is implementation specific. I don't think we need to say anything here.
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.
IDK if it's true that these are only used by the OS - the user agent uses these strings too. Happy for it to be a non-normative note - truncating characters is actually fraught with weirdness due to multi-character sequences now etc, so it would be helpful to document here limits to prevent those breakages.
User agents can't just allow any string here to be displayed in full, as it'll cause weird UX issues with dialogs / menu items / etc. This was the purpose of, say, short_name
.
But - I certainly don't want to block this. And perhaps you are right here @christianliebel that this can be addressed in a separate issue / pull request.
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'll second @dmurph's truncating characters is actually fraught with weirdness.
Example. 🏴
The Scottish flag emoji is 7 code points. The JavaScript string length is 14. It's one grapheme (user perceived character, i.e. screen position). If the short_name
limit is short_name.length < 13
, the flag won't fit...
As a reminder, I18N's guidelines about text truncation apply to length limits. One has to be careful about what one is counting (bytes, code points, graphemes) to ensure that some languages are not disadvantaged because of how their writing system works (emoji makes for a great demo, but there are languages that use combining marks similar to the way emoji sequences work that have the same counting issue)
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.
Created #1145 for further discussion.
I don't think put all languages into one file is a good idea. |
appendix |
@calidion While a general localization schema for web applications and websites may be beneficial, this PR is solely focused on adding localization capabilities specifically to the Web Application Manifest rather than solving broader multi-language support for web applications or websites. I think the WICG Proposals repo would be the right spot to propose and discuss a more general solution. |
@christianliebel But still I hope this feature can be hold for a while before vast agreement would be made. |
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.
Still LGTM, one suggestion to change the example.
</p> | ||
<aside class="example" title="Localizing the application name"> | ||
<pre class="json"> | ||
{ |
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.
In order to make it obvious why one might want to have a different 'lang' for an entry in here, perhaps we should use a company that so it would have opinions about name pronunciations in other languages.
L'Occitane is a good example - using wikipedia you can see that sometimes is uses the french version, while other times it has a translated name. For cases like English & German, screen readers should read the name in a french pronunciation.
{ | |
{ | |
"lang": "fr", | |
"dir": "ltr", | |
"name": "L'Occitane", | |
"name_localized": { | |
"en": { value: "L'Occitane", "lang": "fr" }, | |
"de": { value: "L'Occitane", "lang": "fr" }, | |
"zh": "歐舒丹" | |
"en-GB": {"value": "L'Occitane en Provence", "lang": "fr" }, | |
"fr": "L'Occitane", | |
"ar": {value: "لوکسیتان", "dir": "rtl"} | |
} | |
} |
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.
If it's okay to use real-world brands/examples, that's fine with me. I also have the "Just Eat" example here, where the brand even differs between de-DE and de-CH: #1101 (comment)
@marcoscaceres WDYT?
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.
Sounds good, but don't use a real company name... they might not approve.
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.
The example below seems fine to me... @dmurph?
@@ -2298,7 +2556,9 @@ <h3> | |||
</h3> | |||
<p> | |||
The <dfn>application's name</dfn> is derived from either the | |||
[=manifest/name=] member or [=manifest/short_name=] member. | |||
[=manifest/name=] member or [=manifest/short_name=] member. The user |
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.
In Chromium we use them depending on UX needs. It's not implemented, but I would like to follow similar rules for extensions - short_name
is truncated to 12 characters and name
is truncated to 75.
This sets expectations for devs, and allows the user agent to show an app name where there might not be much space.
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.
This looks ok to me.
Add the trimming any text strings.
Why did you add trimming of localized string values? Leading or trailing whitespace is sometimes significant in localization. Often it is a signal of an I18N bug, but still... users sometimes count on the whitespace being present. |
6e5351c
to
072a8c1
Compare
@aphillips The browser engines trim the values for the default representation fields (example |
No, that answers the question. I'm "at" TPAC, but have a cold, so I'm staying away from giving it to you all. Happy to jump on your Zoom connection if there is more to discuss, though. |
Co-authored-by: Addison Phillips <[email protected]>
072a8c1
to
c400170
Compare
SHA: 75ae2b4 Reason: push, by christianliebel Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Amazing work, Christian! This has been an extremely long standing and complex issue, it's great that you worked your way through it. |
Yes, congrats. Amazing work! |
This is really awesome @christianliebel! Thanks for your work here and being so persistent! |
Thanks @christianliebel! |
Closes #1077, closes #1078, closes #1080, closes #1085, closes #1087, closes #1086, closes #1084, closes #1088, closes #676
This change (choose at least one, delete ones that don't apply):
Implementation commitment (delete if not making normative changes):
If change is normative, and it adds or changes a member:
Commit message:
Add members for localization
Person merging, please make sure that commits are squashed with one of the following as a commit message prefix:
Preview | Diff