Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

String localization does not work when using the static framework #9072

Closed
friedbunny opened this issue May 22, 2017 · 3 comments
Closed

String localization does not work when using the static framework #9072

friedbunny opened this issue May 22, 2017 · 3 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS localization Human language support and internationalization
Milestone

Comments

@friedbunny
Copy link
Contributor

friedbunny commented May 22, 2017

Our replacement NSLocalizedString methods rely on +[NSBundle mgl_frameworkBundle] to provide the Mapbox bundle that contains the localizations.

When using the static Mapbox.framework:

  1. Localizations live in a separate Mapbox.bundle.
  2. +[NSBundle mgl_frameworkBundle] returns the app bundle (not Mapbox.framework or Mapbox.bundle).

This means that localizations never load because we’re looking for them in the base app bundle, not Mapbox.bundle.

(Mapbox.bundle has existed for static builds since #4455.)

Why do images and such work?

For other resources that we load from the bundle, like images or SSL certificates, we manually append Mapbox.bundle to the path using -[NSBundle mgl_resourcesDirectory]:

NSBundle *frameworkBundle = [NSBundle mgl_frameworkBundle];
NSString *resource = [frameworkBundle pathForResource:@"somefile"
                                               ofType:@"extension"
                                          inDirectory:frameworkBundle.mgl_resourcesDirectory];
[NSData dataWithContentsOfFile:resource];

This works, but seems like incorrect behavior: shouldn’t we be treating Mapbox.bundle as the bundle and not just a directory?

/cc @boundsj @1ec5

@friedbunny friedbunny added bug iOS Mapbox Maps SDK for iOS localization Human language support and internationalization labels May 22, 2017
@friedbunny friedbunny self-assigned this May 22, 2017
@friedbunny friedbunny added this to the ios-v3.6.0 milestone May 22, 2017
@friedbunny
Copy link
Contributor Author

Fixed by #9074, will be in v3.6.0-beta.1.

@dungi
Copy link

dungi commented Dec 11, 2017

So does localization no work with MapboxStatic?

@1ec5
Copy link
Contributor

1ec5 commented Dec 11, 2017

@dunqi, this issue was tracking a bug affecting the localization of UI strings within the iOS map SDK, not map labels.

MapboxStatic.swift doesn’t have a localizesLabels option as the iOS map SDK does, but it does allow you to specify a custom style URL. In Mapbox Studio, create a new style based on one of the templates, then change the language of each layer containing labels. Finally, click the “Share, develop & use” button to get the style URL that you can set on SnapshotOptions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS localization Human language support and internationalization
Projects
None yet
Development

No branches or pull requests

3 participants