Re: [w3c/manifest] Add members for localization (PR #1101)

@christianliebel commented on this pull request.



> +                "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"},
+                "ar":    {"value": "منتقي الألوان", "dir": "rtl"}
+              }
+            }
+          </pre>
+        </aside>
+        <p>
+          [=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=] key best
+          matches the user's preference. When no such [=localized value=] is
+          available, the default representation is used.

"Default representation" is already defined, and it refers to the member without the `*_localized` suffix.

It's a good question what should happen in this scenario:

```json
{
  // "name" (default representation) is missing
  "name_localized": {
    "de": "Guten Morgen",
    "fr": "Bonjour"
  }
}
```

We could simply ignore the `*_localized` member if there is no/an invalid default representation (case A).

Or, we could specify a fallback chain:
1. Match the `*_localized` against the user's locale settings and use the best match (case B).
2. If we have a valid `lang` specified at the root level, match the `*_localized` language map against it and use the best match (case C).
3. If there is still no match, ignore the member altogether (case D).

WDYT? @marcoscaceres @dmurph @aphillips 

<details>
<summary>Cases</summary>

## Case A

```json
{
  "name": 123, // invalid name
  "name_localized": {
    "de": "Guten Morgen",
    "fr": "Bonjour"
  }
}
```

| Locale | Result |
| --- | --- |
| `de` | — |
| `fr` | — |
| `en` | — |

## Case B

```json
{
  "name_localized": {
    "de": "Guten Morgen",
    "fr": "Bonjour"
  }
}
```

| Locale | Result |
| --- | --- |
| `de` | Guten Morgen |
| `fr` | Bonjour |
| `en` | — |

## Case C

```json
{
  "lang": "fr",
  "name_localized": {
    "de": "Guten Morgen",
    "fr": "Bonjour"
  }
}
```

| Locale | Result |
| --- | --- |
| `de` | Guten Morgen |
| `fr` | Bonjour |
| `en` | Bonjour |

## Case D

```json
{
  "lang": "en",
  "name_localized": {
    "de": "Guten Morgen",
    "fr": "Bonjour"
  }
}
```

| Locale | Result |
| --- | --- |
| `de` | Guten Morgen |
| `fr` | Bonjour |
| `en` | — |
</details>

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/pull/1101#discussion_r1730368697
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/manifest/pull/1101/review/2259303030@github.com>

Received on Sunday, 25 August 2024 14:22:15 UTC