- [=Localized members=] contain a [=language map=] that defines
- [=localized values=] for different locales denoted by a [=language
- tag=]. If present and if the [=language map=] contains a [=localized
- value=] that matches the user's localization settings, the user agent
- SHOULD override the value of the [=localizable member=].
+ A language map is an [=ordered map=] whose key is a
+ [=language tag=] and whose value is a [=localized value=]. The
+ localized value represents the value applied for the
+ [=language tag=] specified as the key.
-
+
{
"lang": "en-US",
+ "dir": "ltr",
"name": "Color Picker",
"name_localized": {
+ "de": "Farbwähler",
"en": {"value": "Color Picker"},
"en-GB": {"value": "Colour Picker", "dir": "ltr"},
"fr": {"value": "Sélecteur de Couleur", "lang": "fr-CA", "dir": "ltr"},
@@ -1280,125 +1285,189 @@
- The language map is an [=ordered map=] whose key is a
- [=language tag=] and whose value is a [=localized value=]. The
- localized value represents the value applied for the
- [=language tag=] specified as the key. The value matches the type of
- its corresponding [=localizable member=]. For example, a [=localized
- value=] for the [=manifest/name=] member could directly be a
- [=string=].
+ [=manifest/*_localized=] members contain a [=language map=] that
+ defines [=localized values=] for the given [=localizable member=] in
+ the application. The user agent SHOULD use the user's localization
+ settings to select the [=localized value=] whose language tag best
+ matches the user's preference. When no such [=localized value=] is
+ available, the default representation is used.
-
- To support multilingual content and ensure proper display and
- accessibility, it is possible to specify a different language tag and
- text direction for a localized value. This is needed for situations
- where a term or text must be presented in a language different from
- the user's set language.
-
-
- Alternatively, the [=localized value=] can be an [=ordered map=]
- consisting of a `lang`, `dir`, and `value` member, where the `lang`
- member is a [=language tag=], `dir` is a [=text-direction=], and
- `value` contains the localization, matching the type of its
- corresponding [=localizable member=]. The `lang` and `dir` members
- are optional. When they are not set, `lang` matches the [=language
- tag=] of the key, and `dir` matches the [=manifest/dir=] member of
- the [=manifest=].
-
-
-
-
-
+
+
+ Localizing text resources
+
+
+ For [=manifest/*_localized=] members that accept a [=string=] as
+ their value, the [=localized value=] can either be a plain
+ localized [=string=] or an [=ordered map=] containing the following
+ members:
+
+
+
+ `value`
+
+
+ The localized [=string=].
+
+
+ `lang` (optional)
+
+
+ A [=language tag=].
+
+
+ `dir` (optional)
+
+
+ The [=text-direction=].
+
+
+
+ When a plain [=string=] is used, or when the `lang` or `dir`
+ members are omitted, `lang` falls back the [=language tag=] of the
+ [=language map=] key, and `dir` falls back to the [=manifest/dir=]
+ member of the [=manifest=].
+
+
+
+ The `dir` member must be specified if the direction of a
+ localized string differs from the default direction set in the
+ manifest ([=manifest/dir=] member). Right-to-left text will
+ require specific direction settings if the manifest's default
+ direction is left-to-right, and vice versa.
+
+
+ To support multilingual content and ensure proper display and
+ accessibility, it is possible to specify a different [=language
+ tag=] for a [=localized value=]. This is needed for situations
+ where a term or text must be presented in a language different
+ from the user's set language. For example, this helps ensure that
+ an application name is correctly pronounced by assistive
+ technology, even if it is in a foreign language.
+
+
+
+ To process a `*_localized` text member , given [=ordered
+ map=] |json:ordered map|, [=ordered map=] |map:ordered map|,
+ [=string=] |member:string|, and [=text-direction=] |manifest
+ direction:string|:
+
+
+ If |member| does not [=map/exist=] in |json|, return.
+
+ Let |languageMap| be |json|[|member|].
+
+ If |languageMap| is not an [=ordered map=], return.
+
+ Let |languageTags:ordered set| be the [=map/keys=] of
+ |languageMap:ordered map|.
+
+ Set |map|[|member|] to a new [=ordered map=].
+
+ [=Set/For each=] |languageTag:string| of |languageTags|, run
+ [=process a localized text value=], passing
+ |languageMap|[|languageTag|] as the [=localized value=],
+ |languageTag|, |map|, |member|, and |manifest direction|.
+
+
+
+ To process a localized text value , given [=string=] or
+ [=ordered map=] |localizedValue|, [=string=] |languageTag:string|,
+ [=ordered map=] |map:ordered map|, [=string=] |member:string|, and
+ [=text-direction=] |manifest direction:string|:
+
+
+ Let |normalizedValue:ordered map| be an [=ordered map=].
+
+ If |localizedValue| is a [=string=], [=map/set=]
+ |normalizedValue|["value"] to |localizedValue:string|.
+
+ If |localizedValue:ordered map| is an [=ordered map=]:
+
+ If "value" [=map/exists=] in |localizedValue|, [=map/set=]
+ |normalizedValue|["value"] to |localizedValue|["value"].
+
+ If "lang" [=map/exists=] in |localizedValue|, [=map/set=]
+ |normalizedValue|["lang"] to |localizedValue|["lang"].
+
+ If "dir" [=map/exists=] in |localizedValue|, [=map/set=]
+ |normalizedValue|["dir"] to |localizedValue|["dir"].
+
+
+
+ If "value" does not [=map/exist=] in |normalizedValue|, or
+ |normalizedValue|["value"] is not a [=string=], return.
+
+ If "lang" does not [=map/exist=] in |normalizedValue|, or
+ |normalizedValue|["lang"] is not a [=string=], [=map/set=]
+ |normalizedValue|["lang"] to |languageTag|.
+
+ If "dir" does not [=map/exist=] in |normalizedValue|, or
+ [=text-direction list=] does not [=list/contain=]
+ |normalizedValue|["dir"], [=map/set=] |normalizedValue|["dir"] to
+ |manifest direction|.
+
+ [=Map/Set=] |map|[|member|][|languageTag|] to
+ |normalizedValue|.
+
+
+
+ The [=process a localized text value=] algorithm takes both a
+ [=string=] or an [=ordered map=] for the [=localized value=]
+ parameter, but the processed result will be normalized into an
+ [=ordered map=].
+
+
+
+
+ Localizing image resources
+
+
+ For [=manifest/*_localized=] members that accept a [=list=] of
+ [=image resources=] as their value, the [=localized value=] must
+ also be a [=list=] of [=image resources=].
+
+
+
{
"lang": "en-US",
- "dir": "ltr",
- "shortcuts": [{
- "description": "Change language",
- "description_localized": {
- "ar": { "lang": "en", "dir": "ltr", "value": "Change language" }
- },
- "icons": [{
- "src": "/icons/play-later.svg",
- "type": "image/svg+xml"
- }],
- "icons_localized": {
- "ar": [{
- "src": "/icons/ar/play-later.svg",
- "type": "image/svg+xml"
- }]
- }
- }]
+ "icons": [
+ { "src": "icon/lowres.png", "sizes": "64x64" },
+ { "src": "icon/hires.png", "sizes": "256x256" }
+ ],
+ "icons_localized": {
+ "fr": [
+ { "src": "icon/lowres_fr.png", "sizes": "64x64" },
+ { "src": "icon/hires_fr.png", "sizes": "256x256" }
+ ]
+ }
}
-
-
-
- To normalize the localized value , given |localizedValue|,
- [=string=] |languageTag:string|, and [=ordered map=]
- |manifest:ordered map|:
-
-
- Let |normalizedValue| be an [=ordered map=].
-
- If |localizedValue| is an [=ordered map=], and "value"
- [=map/exists=] in |localizedValue|:
-
- [=map/Set=] |normalizedValue|["value"] to
- |localizedValue|["value"].
-
- If "lang" [=map/exists=] in |localizedValue|, [=map/set=]
- |normalizedValue|["lang"] to |localizedValue|["lang"].
-
- If "dir" [=map/exists=] in |localizedValue|, [=map/set=]
- |normalizedValue|["dir"] to |localizedValue|["dir"].
-
-
-
- If "value" does not exist in |normalizedValue|, [=map/set=]
- result["value"] to |localizedValue|.
-
- If "lang" does not exist in |normalizedValue|, [=map/set=]
- |result|["lang"] to |languageTag|.
-
- If "dir" does not exist in |normalizedValue|, [=map/set=]
- |normalizedValue|["dir"] to |manifest|["dir"].
-
- Return |normalizedValue|.
-
-
-
- To process a localizable member , given [=string=]
- |localizableMemberName| and [=ordered map=] |json|:
-
-
- Let |localizedMemberName| be the [=string/concatenation=] of the
- [=list=] « |localizableMemberName|, "_localized" ».
-
- If |localizedMemberName| [=map/exists=] in |json|:
-
- Let |localizedMember| be |json|[|localizedMemberName|].
-
- If |localizedMember| is not an [=ordered map=], continue.
-
-
-
- Let |languageKey| be the most suitable language key based on
- the user's localization settings from the [=map/keys=] of
- |localizedMember|.
-
- If |languageKey| has a value, return the result of
- [=normalize the localized value=], passing
- |localizedMember|[|languageKey|], |languageKey|, and |manifest|.
-
-
-
- If |localizableMemberName| [=map/exists=] in |json|, return the
- result of [=normalize the localized value=], passing
- |json|[|localizableMemberName|], |manifest|["lang"], and |manifest|.
-
- Otherwise, return.
-
-
+
+
+ To process a `*_localized` image resource member , given
+ [=ordered map=] |json:ordered map|, [=ordered map=] |map:ordered
+ map|, [=string=] |member:string|, and [=URL=] |manifest URL:URL|:
+
+
+ If |member| does not [=map/exist=] in |json|, return.
+
+ Let |languageMap| be |json|[|member|].
+
+ If |languageMap| is not an [=ordered map=], return.
+
+ Let |languageTags:ordered set| be the [=map/keys=] of
+ |languageMap:ordered map|.
+
+ [=Map/Set=] |map|[|member|] to a new [=ordered map=].
+
+ [=List/For each=] |languageTag:string| of |languageTags|, run
+ [=process image resources=], passing |languageMap|[|languageTag|]
+ as the [=list=] of [=image resources=], |map|[|member|], |manifest
+ URL|, and |languageTag|.
+
+
+
@@ -1461,9 +1530,15 @@
[=Process a text member=] passing |json|, |manifest|, and
"name".
+ [=Process a `*_localized` text member=] passing |json|,
+ |manifest|, "name_localized", and |manifest|["dir"].
+
[=Process a text member=] passing |json|, |manifest|, and
"short_name".
+ [=Process a `*_localized` text member=] passing |json|,
+ |manifest|, "short_name_localized", and |manifest|["dir"].
+
[=Process the `start_url` member=] passing |json|, |manifest|,
|manifest URL|, and |document URL|.
@@ -1487,6 +1562,9 @@
[=Process image resources=] passing |json|["icons"],
|manifest|, |manifest URL|, and "icons".
+ [=Process a `*_localized` image resource member=] passing
+ |json|, |manifest|, "icons_localized", and |manifest URL|.
+
[=Process the `orientation` member=] passing |json|,
|manifest|.
@@ -2210,8 +2288,7 @@
iconic representations of the shortcut in various contexts.
- This member is a [=localizable member=]. Setting a [=text-direction=]
- is not supported and will be ignored.
+ This member is a [=localizable member=].
@@ -2230,7 +2307,8 @@
To process a shortcut , given [=ordered map=] |item:ordered
- map| and |scope:URL|,:
+ map|, [=URL=] |manifest URL:URL|, [=URL=] |scope:URL|, and [=text-direction=] |manifest
+ direction:string|:
Return failure if it's the case that:
@@ -2258,9 +2336,29 @@
Let |shortcut:ordered map| be |ordered map| «[ "url" → |url|,
"name" → |item|["name"] ]».
+ [=Process a `*_localized` text member=] passing |item|,
+ |shortcut|, "name_localized", and |manifest direction|.
+
+ If "short_name" [=map/exists=] in |item|, and
+ |item|["short_name"] is a [=string=], [=map/set=]
+ |shortcut|["short_name"] to |item|["short_name"].
+
+ [=Process a `*_localized` text member=] passing |item|,
+ |shortcut|, "short_name_localized", and |manifest direction|.
+
+ If "description" [=map/exists=] in |item|, and
+ |item|["description"] is a [=string=], [=map/set=]
+ |shortcut|["description"] to |item|["description"].
+
+ [=Process a `*_localized` text member=] passing |item|,
+ |shortcut|, "description_localized", and |manifest direction|.
+
[=Process image resources=] passing |item|["icons"], |shortcut|,
|manifest URL|, and "icons".
+ [=Process a `*_localized` image resource member=] passing |item|,
+ |shortcut|, "icons_localized", and |manifest URL|.
+
Return |shortcut|.
@@ -3449,7 +3547,10 @@
Authors can provide [=localized values=] for the [=localizable
- members=] of the [=manifest=].
+ members=] of the [=manifest=]. The user agent should pass all
+ localized values to the host operating system. When the user changes
+ the language at the OS level, the OS can immediately display the
+ updated localized values of the [=installed web application=].
Dynamically setting the language: