summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2017-09-28 22:17:27 -0700
committerFredrik Karlsson <bjorn.fredrik.karlsson@gmail.com>2017-10-03 13:28:22 +0200
commitd4992ab0b0a707d53835cf658968972097c7cc81 (patch)
treeec1b31340c57e0d8759fc3896b1e71e9818cc188
parentc07e779bac6865585bce90021120b7a050e93c70 (diff)
downloadqtlocation-mapboxgl-d4992ab0b0a707d53835cf658968972097c7cc81.tar.gz
[ios] Title case based on current orthography
-rw-r--r--platform/darwin/src/NSString+MGLAdditions.m9
1 files changed, 8 insertions, 1 deletions
diff --git a/platform/darwin/src/NSString+MGLAdditions.m b/platform/darwin/src/NSString+MGLAdditions.m
index 371ef4023e..bca6feb1f4 100644
--- a/platform/darwin/src/NSString+MGLAdditions.m
+++ b/platform/darwin/src/NSString+MGLAdditions.m
@@ -12,7 +12,14 @@
- (NSString *)mgl_titleCasedStringWithLocale:(NSLocale *)locale {
NSMutableString *string = self.mutableCopy;
- [string enumerateLinguisticTagsInRange:string.mgl_wholeRange scheme:NSLinguisticTagSchemeLexicalClass options:0 orthography:nil usingBlock:^(NSString * _Nonnull tag, NSRange tokenRange, NSRange sentenceRange, BOOL * _Nonnull stop) {
+ NSOrthography *orthography;
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunguarded-availability-new"
+ if ([NSOrthography respondsToSelector:@selector(defaultOrthographyForLanguage:)]) {
+ orthography = [NSOrthography defaultOrthographyForLanguage:locale.localeIdentifier];
+ }
+#pragma clang diagnostic pop
+ [string enumerateLinguisticTagsInRange:string.mgl_wholeRange scheme:NSLinguisticTagSchemeLexicalClass options:0 orthography:orthography usingBlock:^(NSString * _Nonnull tag, NSRange tokenRange, NSRange sentenceRange, BOOL * _Nonnull stop) {
NSString *word = [string substringWithRange:tokenRange];
if (word.length > 3
|| !([tag isEqualToString:NSLinguisticTagConjunction]