You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by cs...@apache.org on 2015/09/10 23:41:09 UTC
cordova-plugin-globalization git commit: CB-9409 check that
localeIdentifier has underscore
Repository: cordova-plugin-globalization
Updated Branches:
refs/heads/master ca37f40ac -> 1e6f24ee0
CB-9409 check that localeIdentifier has underscore
CB-9409 change the condition checking for underscore. This closes #39
github: close #39
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/1e6f24ee
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/1e6f24ee
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/1e6f24ee
Branch: refs/heads/master
Commit: 1e6f24ee0b8ea7b6be593fb1c4ef5e2beb134698
Parents: ca37f40
Author: Edna Morales <ed...@gmail.com>
Authored: Fri Jul 24 16:45:26 2015 -0400
Committer: Carlos Santana <cs...@gmail.com>
Committed: Thu Sep 10 17:37:58 2015 -0400
----------------------------------------------------------------------
src/ios/CDVGlobalization.m | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/1e6f24ee/src/ios/CDVGlobalization.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVGlobalization.m b/src/ios/CDVGlobalization.m
index 49691a0..7ba1f6f 100644
--- a/src/ios/CDVGlobalization.m
+++ b/src/ios/CDVGlobalization.m
@@ -39,14 +39,17 @@
//Format to match other devices
if(language.length <= 2) {
NSLocale* locale = [NSLocale currentLocale];
- NSRange underscoreIndex = [[locale localeIdentifier] rangeOfString:@"_" options:NSBackwardsSearch];
- NSRange atSignIndex = [[locale localeIdentifier] rangeOfString:@"@"];
- //If localeIdentifier did not contain @, i.e. did not have calendar other than Gregoarian selected
- if(atSignIndex.length == 0)
- language = [NSString stringWithFormat:@"%@%@", language, [[locale localeIdentifier] substringFromIndex:underscoreIndex.location]];
- else {
- NSRange localeRange = NSMakeRange(underscoreIndex.location, atSignIndex.location-underscoreIndex.location);
- language = [NSString stringWithFormat:@"%@%@", language, [[locale localeIdentifier] substringWithRange:localeRange]];
+ NSString* localeId = [locale localeIdentifier];
+ NSRange underscoreIndex = [localeId rangeOfString:@"_" options:NSBackwardsSearch];
+ NSRange atSignIndex = [localeId rangeOfString:@"@"];
+ if (underscoreIndex.location != NSNotFound) {
+ //If localeIdentifier did not contain @, i.e. did not have calendar other than Gregoarian selected
+ if(atSignIndex.length == 0)
+ language = [NSString stringWithFormat:@"%@%@", language, [localeId substringFromIndex:underscoreIndex.location]];
+ else {
+ NSRange localeRange = NSMakeRange(underscoreIndex.location, atSignIndex.location-underscoreIndex.location);
+ language = [NSString stringWithFormat:@"%@%@", language, [localeId substringWithRange:localeRange]];
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org