File tree 2 files changed +9
-31
lines changed
MJRefresh.bundle/ru.lproj
2 files changed +9
-31
lines changed Original file line number Diff line number Diff line change @@ -140,26 +140,20 @@ - (NSString *)localizedStringForKey:(NSString *)key{
140
140
- (NSString *)localizedStringForKey : (NSString *)key withDefault : (NSString *)defaultString
141
141
{
142
142
static NSBundle *bundle = nil ;
143
- if (bundle == nil )
144
- {
145
- NSString *bundlePath = [[NSBundle mainBundle ] pathForResource: @" MJRefresh" ofType: @" bundle" ];
146
-
147
- bundle = [NSBundle bundleWithPath: bundlePath];
148
- NSString *language = [[NSLocale preferredLanguages ] count ]? [NSLocale preferredLanguages ][0 ]: @" en" ;
143
+ if (bundle == nil ) {
144
+ // 获得设备的语言
145
+ NSString *language = [NSLocale preferredLanguages ].firstObject ;
146
+ // 如果是iOS9以上,截取前面的语言标识
149
147
if ([UIDevice currentDevice ].systemVersion .floatValue >= 9.0 ) {
150
148
NSRange range = [language rangeOfString: @" -" options: NSBackwardsSearch];
151
149
language = [language substringToIndex: range.location];
152
150
}
153
- if (![[bundle localizations ] containsObject: language])
154
- {
155
- language = [language componentsSeparatedByString: @" -" ][0 ];
156
- }
157
- if ([[bundle localizations ] containsObject: language])
158
- {
159
- bundlePath = [bundle pathForResource: language ofType: @" lproj" ];
151
+
152
+ // 先从MJRefresh.bundle中查找资源
153
+ NSBundle *refreshBundle = [NSBundle bundleWithPath: [[NSBundle mainBundle ] pathForResource: @" MJRefresh" ofType: @" bundle" ]];
154
+ if ([refreshBundle.localizations containsObject: language]) {
155
+ bundle = [NSBundle bundleWithPath: [refreshBundle pathForResource: language ofType: @" lproj" ]];
160
156
}
161
-
162
- bundle = [NSBundle bundleWithPath: bundlePath] ?: [NSBundle mainBundle ];
163
157
}
164
158
defaultString = [bundle localizedStringForKey: key value: defaultString table: nil ];
165
159
return [[NSBundle mainBundle ] localizedStringForKey: key value: defaultString table: nil ];
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments