Skip to content

Commit

Permalink
Fallback to name:en for unsupported scripts with one script section (#…
Browse files Browse the repository at this point in the history
…293)

* Fallback to name:en for unsupported scripts with one script section
  • Loading branch information
wipfli authored Aug 25, 2024
1 parent b6b976d commit 60e7d48
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions styles/src/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,46 @@ export function get_multiline_name(lang: string, script?: string) {
is_not_in_target_script(lang, _script, "name"),
// `name` is not in the target script
[
"format",
"case",
[
"coalesce",
["get", `${name_prefix}name:${lang}`],
["get", "name:en"], // Always fallback to English
"any",
["is-supported-script", ["get", "name"]],
["has", "pmap:pgf:name"],
],
get_font_formatting(_script),
"\n",
{},
// `name` can be rendered correctly
[
"case",
"format",
[
"all",
["!", ["has", `${name_prefix}name:${lang}`]],
["has", "name:en"],
["!", ["has", "pmap:script"]],
"coalesce",
["get", `${name_prefix}name:${lang}`],
["get", "name:en"], // Always fallback to English
],
// We did fallback to English in the first line and `name` is Latin
"",
["coalesce", ["get", "pmap:pgf:name"], ["get", "name"]],
],
{
"text-font": [
get_font_formatting(_script),
"\n",
{},
[
"case",
["==", ["get", "pmap:script"], "Devanagari"],
["literal", ["Noto Sans Devanagari Regular v1"]],
["literal", ["Noto Sans Regular"]],
[
"all",
["!", ["has", `${name_prefix}name:${lang}`]],
["has", "name:en"],
["!", ["has", "pmap:script"]],
],
// We did fallback to English in the first line and `name` is Latin
"",
["coalesce", ["get", "pmap:pgf:name"], ["get", "name"]],
],
},
{
"text-font": [
"case",
["==", ["get", "pmap:script"], "Devanagari"],
["literal", ["Noto Sans Devanagari Regular v1"]],
["literal", ["Noto Sans Regular"]],
],
},
],
// `name` cannot be rendered correctly, fallback to `name:en`
["get", "name:en"],
],
// `name` is in the target script
[
Expand Down

0 comments on commit 60e7d48

Please sign in to comment.