Technical review: Document web app manifest localization#44609
Technical review: Document web app manifest localization#44609chrisdavidmills wants to merge 8 commits into
Conversation
|
Preview URLs (4 pages)
External URLs (4)URL:
URL:
(comment last updated: 2026-07-03 08:17:10) |
|
|
||
| in this example, the app's default `lang` is `en-US`, and its default `dir` is `ltr`. Its default `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. | ||
|
|
||
| The French variant is specified as French Canadian (`fr-CA`) in its `lang` property, with a direction (`dir`) of `ltr`, while the Arabic variant has its `dir` specified as `rtl`. The German variant doesn't need its `lang` or `dir` specified, so its value is a string containing the localized text. |
There was a problem hiding this comment.
This doesn't quite work because the French Canadian version doesn't need its direction set either.
| "name": "Color Picker", | ||
| "name_localized": { | ||
| "de": "Farbwähler", | ||
| "fr": { "value": "Sélecteur de Couleur", "lang": "fr-CA", "dir": "ltr" }, |
There was a problem hiding this comment.
How does this work - i.e this is fr, but you also have a lang that is "fr-CA". However I know lang sets the default language.
My guess is that this should omit lang and fix up the key.
"fr-CA": { "value": "Sélecteur de Couleur", "dir": "ltr" },
Further, in the intro it says "will see the app's name displayed in a more suitable language for them."
I would like to understand the fallback here. If my language is set to fr, will it choose "fr-CA" or will it choose English ? Can I declare both "fr" and "fr-CA", and so on. The example could show a case or two.
There was a problem hiding this comment.
There was a problem hiding this comment.
Definitely see https://github.com/mdn/content/pull/44609/changes#r3517481036 :-)
| --- | ||
|
|
||
| The `lang` manifest member is used to specify a default language for your web application, which will be used unless overriden by a different `lang` value found in a [`*_localized`](/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/*_localized) member. | ||
|
|
There was a problem hiding this comment.
Is there a default lang assumed?
|
|
||
| in this example, the app's default `lang` is `en-US`, and its default `dir` is `ltr`. Its default `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. | ||
|
|
||
| The French variant is specified as French Canadian (`fr-CA`) in its `lang` property, with a direction (`dir`) of `ltr`, while the Arabic variant has its `dir` specified as `rtl`. The German variant doesn't need its `lang` or `dir` specified, so its value is a string containing the localized text. |
There was a problem hiding this comment.
Same comments as for the lang case.
Note also that this is a dir topic. I'd show a screen shot or explicitly state at least somewhere that the text will be drawn LTR and show it.
| page-type: how-to | ||
| sidebar: pwasidebar | ||
| --- | ||
|
|
There was a problem hiding this comment.
How do I localise the rest of the app? We should at least mention that (or if it can't be done, state that too). I assume perhaps we can specify a key for the default language entry point?
There was a problem hiding this comment.
Localizing the rest of the app is a huge topic and out of scope for this article. How you would go about localizing it depends on what kind of app it is, what stack you've used, etc.
https://github.com/oh-jon-paul/awesome-i18n gives you an idea of what's available.
|
|
||
| ## Set a default language and direction | ||
|
|
||
| The [`lang`](/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/lang) and [`dir`](/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/dir) members define a default language and language direction for the app. These will be assumed by the browser if no language and direction more suitable for the user's preferences are found in the [`*_localized`](/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/*_localized) variants. In such cases, the non-prefixed members are used (for example, `name`). |
There was a problem hiding this comment.
-
What if I don't set a default language or dir, what is used?
-
While I understand exactly what you mean, this doesn't feel quite right
These will be assumed by the browser if no language and direction more suitable for the user's preferences are found in the
*_localizedvariants.It's because the languages will be used but it isn't
langanddirthat will be used. What will be used is the other non-localized members. You clarify this in the next sentence, but "These" still grates.
| sidebar: pwasidebar | ||
| --- | ||
|
|
||
| The `lang` manifest member is used to specify a default language for your web application, which will be used unless overriden by a different `lang` value found in a [`*_localized`](/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/*_localized) member. |
There was a problem hiding this comment.
I'm nearing the end of my review, and I realize that this first doc that I read in the review is confusing:
overriden by a different
langvalue found in a*_localizedmember.
If it specifies the default language for my web application, what sense does it make to override?
| }, | ||
| ``` | ||
|
|
||
| The French (`fr`) `short_name` translation shows typical usage of the object value form being used to specify a `lang` property. In this case, our French audience knows our app by its English brand name — "SuperSausage" — and we want to specify that this should be handled as English rather than French (for example, for the purposes of pronounciation). |
There was a problem hiding this comment.
See https://github.com/mdn/content/pull/44609/changes#r3517481036 - lang in a translation needs additional explanation there. I think I get it now, finally on this the second last doc - this allows you to specify that the value from some other language key should be used for a translation, instead of providing your own, or using the default?
Typo too
| The French (`fr`) `short_name` translation shows typical usage of the object value form being used to specify a `lang` property. In this case, our French audience knows our app by its English brand name — "SuperSausage" — and we want to specify that this should be handled as English rather than French (for example, for the purposes of pronounciation). | |
| The French (`fr`) `short_name` translation shows typical usage of the object value form being used to specify a `lang` property. In this case, our French audience knows our app by its English brand name — "SuperSausage" — and we want to specify that this should be handled as English rather than French (for example, for the purposes of pronunciation). |
|
|
||
| ## Finished manifest | ||
|
|
||
| Putting this all together, the complete manifest looks like this: |
There was a problem hiding this comment.
I think you need your shortcuts - I want to know how to select my language version.
|
|
||
| Localized text field properties have values equal to objects or strings. | ||
|
|
||
| in this example, the app's default `en-US` language `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. |
There was a problem hiding this comment.
| in this example, the app's default `en-US` language `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. | |
| In this example, the app's default `en-US` language `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. |
There was a problem hiding this comment.
But also see my other comment on lang - this could be better worded.
|
|
||
| in this example, the app's default `en-US` language `name` is "Color picker", but we've also specified localized variants in the `name_localized` member. Users that have their primary language preference set to German (`de`), French (`fr`), or Arabic (`ar`) will see the app's name displayed in a more suitable language for them. | ||
|
|
||
| The French variant is specified as French Canadian (`fr-CA`) in its `lang` property, with a direction (`dir`) of `ltr`, while the Arabic variant has its `dir` specified as `rtl`. The German variant doesn't need its `lang` or `dir` specified, so its value is a string containing the localized text. |
There was a problem hiding this comment.
It isn't clear why the French version needs a lang and dir and the german version does not - same thing as https://github.com/mdn/content/pull/44609/changes#r3517444725
Somewhere else, perhaps in the how to, you indicate that lange in a localized member takes a language from somewhere else. So here you're saying that for French ou take your language from "fr-CA". But then there are two more questions:
- If you are taking it from fr-CA, where is your fr-CA definition?
- If you are taking it from fr-CA, why do you have a value?
I suspect the answer might be "take it from fr-CA if defined and otherwise fall back to the specified value. But that feels like poor design to me.
|
|
||
| The `lang` and `dir` members define a default language and language direction that will be assumed by the browser if no language more suitable for the user's preferences is found in the `name_localized` variants. In such cases, the `name` member is used. | ||
|
|
||
| ### Localized images |
There was a problem hiding this comment.
Is it icons or image or both? If it can only be icons we should say that. If icons and other images are different we should say that. We should also note "somewhere" whether the localised set can have diferrent sets of icons or must match the same sizes
…ndex.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…dex.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…dex.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…nifest/index.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…nifest/index.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…nifest/index.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
…nifest/index.md Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Description
Chrome and Edge 148 desktop have added support for
*_localizedmembers, aka localizable web app manifests. See https://chromestatus.com/feature/5090807862394880.This PR adds reference documentation for
*_localizedmembers and thedirandlangmembers, as well as a how-to guide covering how to localize a web app manifest.Motivation
Additional details
Related issues and pull requests