Skip to content

Commit

Permalink
本地化问题
Browse files Browse the repository at this point in the history
语言字符串截取的严谨判断
  • Loading branch information
520dev committed Jun 14, 2016
1 parent b28ed99 commit 4e7ead8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MJRefresh.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MJRefresh'
s.version = '3.1.3'
s.version = '3.1.4'
s.summary = 'An easy way to use pull-to-refresh'
s.homepage = 'https://github.com/CoderMJLee/MJRefresh'
s.license = 'MIT'
Expand Down
4 changes: 3 additions & 1 deletion MJRefresh/Base/MJRefreshComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ - (NSString *)localizedStringForKey:(NSString *)key withDefault:(NSString *)defa
// 如果是iOS9以上,截取前面的语言标识
if ([UIDevice currentDevice].systemVersion.floatValue >= 9.0) {
NSRange range = [language rangeOfString:@"-" options:NSBackwardsSearch];
language = [language substringToIndex:range.location];
if (range.location != NSNotFound) {

This comment has been minimized.

Copy link
@soundtravel

soundtravel Jun 15, 2016

这样改不对呀,zh-Hans被截成zh了,bundle里面就找不到本地化资源了

language = [language substringToIndex:range.location];
}
}

if (language.length == 0) {
Expand Down

3 comments on commit 4e7ead8

@CoderMJLee
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soundtravel 当系统版本大于等于9.0时,language并不是zh-Hans,而是zh-Hans-US哈

@soundtravel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥我用真机和模拟器测的都是zh-Hans呢。。版本是iOS9.3

@CoderMJLee
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个返回的值一直都不太稳定,在很久以前返回的一直是zh-Hans,从iOS9开始,有些版本和机器返回的是zh-Hans-US或者zh-Hans-CN,后面的CN和US取决于设备上设置的区域

Please sign in to comment.