summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSBundle+MGLAdditions.h
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-21 11:10:41 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-24 16:13:08 -0700
commit6c9ca4be50e74a260d9cc2bc731fe56d85c353d2 (patch)
treef18339e7adc6b293b39c6765d6a4aa31188af6ce /platform/darwin/src/NSBundle+MGLAdditions.h
parentfd93cf969d060b5fee95a9c94097a92ab665d2d8 (diff)
downloadqtlocation-mapboxgl-6c9ca4be50e74a260d9cc2bc731fe56d85c353d2.tar.gz
[ios] Made SDK and iosapp localizable
Made storyboards and strings throughout the SDK and iosapp localizable. Replaced the compass image with an unlabeled image. Draw a localizable string atop it at runtime. Redefined NSLocalizedString() and NSLocalizedStringFromTable() macros to look at the SDK bundle rather than the main application bundle. This redefinition has no effect on the host application, because it’s in an internal header. That header must be included in all files that contain localizable strings. See NSBundle+MGLAdditions.h for a full explanation. Added a make rule that runs genstrings and ensures UTF-8 output (since genstrings insists on UTF-16). Use MGLCoordinateFormatter in iosapp for dropped pin callouts. Rely on subclasses of MGLPointAnnotation instead of annotation titles to distinguish between different kinds of point annotations.
Diffstat (limited to 'platform/darwin/src/NSBundle+MGLAdditions.h')
-rw-r--r--platform/darwin/src/NSBundle+MGLAdditions.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/darwin/src/NSBundle+MGLAdditions.h b/platform/darwin/src/NSBundle+MGLAdditions.h
index 8a3e5c3c2e..bab70f38bc 100644
--- a/platform/darwin/src/NSBundle+MGLAdditions.h
+++ b/platform/darwin/src/NSBundle+MGLAdditions.h
@@ -4,6 +4,25 @@
NS_ASSUME_NONNULL_BEGIN
+// Strings in the SDK targets must be retrieved from the framework bundle rather
+// than the main bundle, which is usually the application bundle. Redefining
+// these macros ensures that the framework bundle’s string tables are used at
+// runtime yet tools like genstrings and Xcode can still find the localizable
+// string identifiers. (genstrings has an -s option that would allow us to
+// define our own macros, but Xcode’s Export Localization feature lacks support
+// for it.)
+//
+// As a consequence of this approach, this header must be included in all SDK
+// files that include localizable strings.
+
+#undef NSLocalizedString
+#define NSLocalizedString(key, comment) \
+ [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:nil]
+
+#undef NSLocalizedStringFromTable
+#define NSLocalizedStringFromTable(key, tbl, comment) \
+ [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:(tbl)]
+
@interface NSBundle (MGLAdditions)
/// Returns the bundle containing the SDK’s classes and Info.plist file.