summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2018-12-08 01:43:13 -0800
committerMinh Nguyễn <mxn@1ec5.org>2018-12-08 02:18:56 -0800
commit3dffb1fd5354829de6c4e6f39d016c389142f92e (patch)
treeb84e1afe5628d42e2a3b8fb98e400eb857ca16ab
parentfca084b92322c5915d3361ef21c6ea80ed252aed (diff)
downloadqtlocation-mapboxgl-3dffb1fd5354829de6c4e6f39d016c389142f92e.tar.gz
[ios] Added CJK string transforms
-rw-r--r--platform/darwin/src/NSString+MGLAdditions.m8
-rw-r--r--platform/darwin/test/MGLNSStringAdditionsTests.m21
-rw-r--r--platform/ios/src/NSOrthography+MGLAdditions.m6
3 files changed, 34 insertions, 1 deletions
diff --git a/platform/darwin/src/NSString+MGLAdditions.m b/platform/darwin/src/NSString+MGLAdditions.m
index d645490eb3..d452d56678 100644
--- a/platform/darwin/src/NSString+MGLAdditions.m
+++ b/platform/darwin/src/NSString+MGLAdditions.m
@@ -46,11 +46,17 @@
if ([script isEqualToString:@"Latn"]) {
transform = NSStringTransformToLatin;
} else if ([script isEqualToString:@"Hans"]) {
- // No transform available.
+ transform = @"Hant-Hans";
+ } else if ([script isEqualToString:@"Hant"]) {
+ transform = @"Hans-Hant";
} else if ([script isEqualToString:@"Cyrl"]) {
transform = @"Any-Latin; Latin-Cyrillic";
} else if ([script isEqualToString:@"Arab"]) {
transform = @"Any-Latin; Latin-Arabic";
+ } else if ([script isEqualToString:@"Jpan"]) {
+ transform = @"Any-Latin; Latin-Katakana";
+ } else if ([script isEqualToString:@"Kore"]) {
+ transform = @"Any-Latin; Latin-Hangul";
}
return transform ? [string stringByApplyingTransform:transform reverse:NO] : string;
}
diff --git a/platform/darwin/test/MGLNSStringAdditionsTests.m b/platform/darwin/test/MGLNSStringAdditionsTests.m
index a3ee7e3433..571cf49d7f 100644
--- a/platform/darwin/test/MGLNSStringAdditionsTests.m
+++ b/platform/darwin/test/MGLNSStringAdditionsTests.m
@@ -42,26 +42,47 @@
- (void)testTransliteratedString {
XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Latn"], @"Portland");
XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Hans"], @"Portland");
+ XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Hant"], @"Portland");
XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"Портланд");
XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Arab"], @"پُرتلَند");
+ XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ポルテランデ");
+ XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Kore"], @"폹란드");
XCTAssertEqualObjects([@"Portland" mgl_stringByTransliteratingIntoScript:@"Fake"], @"Portland");
XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Latn"], @"běi jīng");
XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Hans"], @"北京");
+ XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Hant"], @"北京");
XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"бе̌и йӣнг");
XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Arab"], @"بِِ̌ جِينگ");
+ XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ベ̌イ ジーング");
+ XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Kore"], @"베̌이 지̄늑");
XCTAssertEqualObjects([@"北京" mgl_stringByTransliteratingIntoScript:@"Fake"], @"北京");
+
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Latn"], @"jiǔ lóng");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Hans"], @"九龙");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Hant"], @"九龍");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"йиу̌ ло́нг");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Arab"], @"جُِ̌ لُ́نگ");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ジウ̌ ロ́ング");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Kore"], @"지우̌ 로́늑");
+ XCTAssertEqualObjects([@"九龍" mgl_stringByTransliteratingIntoScript:@"Fake"], @"九龍");
XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Latn"], @"Moskva");
XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Hans"], @"Mосква");
+ XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Hant"], @"Mосква");
XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"Москва");
XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Arab"], @"مُسكڤَ");
+ XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"モスクヷ");
+ XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Kore"], @"못크바");
XCTAssertEqualObjects([@"Mосква" mgl_stringByTransliteratingIntoScript:@"Fake"], @"Mосква");
XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Latn"], @"rondon");
XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Hans"], @"ロンドン");
+ XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Hant"], @"ロンドン");
XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Cyrl"], @"рондон");
XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Arab"], @"رُندُن");
+ XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Jpan"], @"ロンドン");
+ XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Kore"], @"론돈");
XCTAssertEqualObjects([@"ロンドン" mgl_stringByTransliteratingIntoScript:@"Fake"], @"ロンドン");
}
diff --git a/platform/ios/src/NSOrthography+MGLAdditions.m b/platform/ios/src/NSOrthography+MGLAdditions.m
index 99258862cc..f48a2ffcbe 100644
--- a/platform/ios/src/NSOrthography+MGLAdditions.m
+++ b/platform/ios/src/NSOrthography+MGLAdditions.m
@@ -18,10 +18,16 @@
return @"Latn";
} else if ([hansLanguages containsObject:language]) {
return @"Hans";
+ } else if ([language isEqualToString:@"zh-Hant"]) {
+ return @"Hant";
} else if ([language isEqualToString:@"ru"]) {
return @"Cyrl";
} else if ([language isEqualToString:@"ar"]) {
return @"Arab";
+ } else if ([language isEqualToString:@"ja"]) {
+ return @"Jpan";
+ } else if ([language isEqualToString:@"ko"]) {
+ return @"Kore";
} else {
// Code for undetermined script
return @"Zyyy";