Open hohMiyazawa opened 2 months ago
(Is the name of countries special cased BTW? When selecting "language=nn", Chad is incorrectly spelled "Tchad", even though the name:nn
key has correctly been "Tsjad" for many years in OSM)
If a user selects "language=nn" (Norwegian Nynorsk), they want
name:nn
displayed on the map, but if no such key is present, the map should usename:no
if it exists. In the same way, if a user selects "language=nb" (Norwegian Bokmål),name:no
should be used as a fallback forname:nb
.
Admittedly the language fallback logic is not very sophisticated. Here’s where it lives:
We could certainly add these special cases for Norwegian, since they’re pretty straightforward. More subjective fallbacks should probably be a server-side responsibility when generating the tiles, since the MapLibre expression language doesn’t give us very thorough text processing capabilities.
If a user selects "language=no" (Norwegian), if a
name:no
key is missing, the keysname:nn
andname:nb
should be used as fallback. This however only works if only one of them is present. If they are both present, they would need to be the same to be used. If they are different, one would have to open the can of worms of picking one of them as preferred, if one doesn't do something like peeking at the browser language to check which of the two forms the user prefers.
Most browsers or operating systems have a setting that lets you list languages in a preferred order. We do support this setting. You can manually specify Bokmål or Nynorsk as a fallback using the widget in the lower-right corner of the map. Alternatively, you can set the language
URL parameter to a comma-separated list of locales, such as nn,no
.
Is the name of countries special cased BTW?
Yes, the vector tiles don’t actually indicate the name of the administrative area on either side of a boundary, just the country code, so the boundary edge labels rely on your Web browser to convert the country code into a name in your preferred language. Most browsers get these names from the CLDR project. We would prefer to get the names from the tiles, for consistency with the main country labels, but this is the best we can do for now. You can contribute to CLDR, which will improve the state of localization industry-wide.
Is this the logic that's requested?
nn
means nn,no
nb
means nb,no
?
This sounds similar to the case with simplified and traditional Chinese, which might both fall back to zh
.
Yes, that's the gist of it.
The problem is what to do when being requested no
("I want these names in Norwegian"). I suppose that runs into the same issues as zh
.
Being able to select a preferred display language for names is awesome! Currently though, Norwegian language codes aren't working perfectly out of the box.
Quick rundown of the situation:
Norwegian, with the language code
no
is one language. It does however have two written forms:nn
nb
Both written forms are equal under the law, Norwegians learn both in school, but there is a geographic divide in which of the two forms is more commonly used.
For place names though, they rarely disagree. This means Norwegian names for places are usually using the key
name:no
, with the keysname:nn
andname:nb
mostly being used when the spelling is different. (Though names abroad sometimes use both these keys too even when they are equal).That means:
name:nn
displayed on the map, but if no such key is present, the map should usename:no
if it exists. Usingname:nb
as a further fallback depends on the usecase.name:no
should be used as a fallback forname:nb
.name:no
key is missing, the keysname:nn
andname:nb
should be used as fallback. This however only works if only one of them is present. If they are both present, they would need to be the same to be used. If they are different, one would have to open the can of worms of picking one of them as preferred, if one doesn't do something like peeking at the browser language to check which of the two forms the user prefers.Just another slightly complicated language situation out there :)