Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Norwegian names and language codes #1114

Open
hohMiyazawa opened this issue Jun 27, 2024 · 4 comments
Open

Norwegian names and language codes #1114

hohMiyazawa opened this issue Jun 27, 2024 · 4 comments
Labels
internationalization openmaptiles A change is needed in OpenMapTiles to support this

Comments

@hohMiyazawa
Copy link

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:

  • Nynorsk, with the language code nn
  • Bokmål, with the language codes 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 keyname:no, with the keys name:nn and name: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:

  • 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 use name:no if it exists. Using name:nb as a further fallback depends on the usecase.
  • In the same way, if a user selects "language=nb" (Norwegian Bokmål), name:no should be used as a fallback for name:nb.
  • If a user selects "language=no" (Norwegian), if a name:no key is missing, the keys name:nn and name: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 :)

@hohMiyazawa
Copy link
Author

(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)

@1ec5
Copy link
Member

1ec5 commented Jun 28, 2024

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 use name: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 for name:nb.

Admittedly the language fallback logic is not very sophisticated. Here’s where it lives:

https://github.com/ZeLonewolf/openstreetmap-americana/blob/d4a95a6a9080b0b4032137719d7729a1622c8b59/src/constants/label.js#L14-L32

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 keys name:nn and name: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.

@1ec5 1ec5 added openmaptiles A change is needed in OpenMapTiles to support this internationalization labels Jun 28, 2024
@ZeLonewolf
Copy link
Member

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.

@hohMiyazawa
Copy link
Author

hohMiyazawa commented Jun 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internationalization openmaptiles A change is needed in OpenMapTiles to support this
Projects
None yet
Development

No branches or pull requests

3 participants