Skip to content

Unable to unlocalize a layer’s labels #653

@1ec5

Description

@1ec5

Style.localizeLabels(into:forLayerIds:) should have a way to explicitly unlocalize a layer’s labels – that is, make it show names in the local language instead of a specific passed-in language. This was supported in Mapbox Maps SDK v6.x but has regressed as of #480.

Rationale

It should be possible to easily undo what Style.localizeLabels(into:forLayerIds:) does when passing in a specific locale.

It should also be possible to ensure that a layer matches the local language, in the event that the original style hard-coded a particular language. For example, the Mapbox Navigation Day/Night v1 styles hard-code English in its road labels, falling back to the local language. This is suboptimal for the Mapbox Navigation SDK, which is marketed around the world, so it would be beneficial to force the local language name instead of English.

Design considerations

In v6.x and the proof-of-concept port in mapbox/mapbox-navigation-ios#2933, -[NSExpression mgl_expressionLocalizedIntoLocale:] supports two special Locale values, both documented:

  • nil automatically selects the first language listed in the system Preferred Content Languages list (+[NSLocale preferredLanguages]) that is also supported by the Streets source.
  • A Locale with the identifier mul (the standard ISO 639-2 code for multilingual text) selects the name field, which is typically in the local language.

Unfortunately, neither of these options are available in v10. The locale argument is non-optional, though it isn’t a big deal to pass in the first value in NSLocale.preferredLanguages manually. More problematic is that passing in mul currently crashes, because it isn’t one of the hard-coded locale codes supported by Streets:

guard let localeValue = getLocaleValue(locale: locale) else {
fatalError("This locale is not supported")
}

/cc @mapbox/maps-ios @mapbox/navigation-ios

Metadata

Metadata

Assignees

No one assigned

    Labels

    archivedbug 🪲Something is broken!feature 🍏When working on a new feature or feature enhancementp2

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions