-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
支持本地化(国际化)
- Loading branch information
Showing
14 changed files
with
116 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// 代码地址: https://github.com/iphone5solo/PYSearch | ||
// 代码地址: http://www.code4app.com/thread-11175-1-1.html | ||
// Created by CoderKo1o. | ||
// Copyright © 2016年 iphone5solo. All rights reserved. | ||
// NSString 分类 | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSString (PYSearchExtension) | ||
|
||
/** 获取本地化字符串 */ | ||
- (NSString *)py_localizedString; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// 代码地址: https://github.com/iphone5solo/PYSearch | ||
// 代码地址: http://www.code4app.com/thread-11175-1-1.html | ||
// Created by CoderKo1o. | ||
// Copyright © 2016年 iphone5solo. All rights reserved. | ||
// | ||
|
||
#import "NSString+PYSearchExtension.h" | ||
|
||
@implementation NSString (PYSearchExtension) | ||
|
||
- (NSString *)py_localizedString | ||
{ | ||
return [self py_localizedStringForKey:self value:nil]; | ||
} | ||
|
||
- (NSString *)py_localizedStringForKey:(NSString *)key value:(NSString *)value | ||
{ | ||
static NSBundle *bundle = nil; | ||
if (bundle == nil) { | ||
// 只处理en、zh-Hans、zh-Hant三种情况,其他按照系统默认处理 | ||
NSString *language = [NSLocale preferredLanguages].firstObject; | ||
if ([language hasPrefix:@"en"]) { | ||
language = @"en"; | ||
} else if ([language hasPrefix:@"zh"]) { | ||
if ([language rangeOfString:@"Hans"].location != NSNotFound) { | ||
language = @"zh-Hans"; // 简体中文 | ||
} else { // zh-Hant\zh-HK\zh-TW | ||
language = @"zh-Hant"; // 繁體中文 | ||
} | ||
} else { | ||
language = @"en"; | ||
} | ||
|
||
// 从PYSearch.bundle中查找资源 | ||
bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"PYSearch" ofType:@"bundle"]]; | ||
} | ||
value = [bundle localizedStringForKey:key value:value table:nil]; | ||
return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; | ||
} | ||
|
||
@end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"PYSearchSearchPlaceholderText" = "Search content"; | ||
"PYSearchHotSearchText" = "Popular searches"; | ||
"PYSearchSearchHistoryText" = "Search history"; | ||
"PYSearchEmptySearchHistoryText" = "Clear the search history"; | ||
|
||
"PYSearchEmptyButtonText" = "Clear"; | ||
"PYSearchEmptySearchHistoryLogText" = "Clear the search history"; | ||
"PYSearchCancelButtonText" = "Cancel"; |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"PYSearchSearchPlaceholderText" = "搜索內容"; | ||
"PYSearchHotSearchText" = "熱門搜索"; | ||
"PYSearchSearchHistoryText" = "搜索歷史"; | ||
"PYSearchEmptySearchHistoryText" = "清空搜索歷史"; | ||
|
||
"PYSearchEmptyButtonText" = "清空"; | ||
"PYSearchEmptySearchHistoryLogText" = "清空搜索歷史"; | ||
"PYSearchCancelButtonText" = "取消"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
// | ||
// 代码地址: https://github.com/iphone5solo/PYSearch | ||
// 代码地址: http://www.code4app.com/thread-11175-1-1.html | ||
// Created by CoderKo1o. | ||
// Copyright © 2016年 iphone5solo. All rights reserved. | ||
// | ||
|
||
#import "PYSearchConst.h" | ||
#import <UIKit/UIKit.h> | ||
|
||
NSString *const PYSearchPlaceholderText = @"搜索内容"; // 搜索框的占位符 默认为 @"搜索内容" | ||
NSString *const PYHotSearchText = @"热门搜索"; // 热门搜索文本 默认为 @"热门搜索" | ||
NSString *const PYSearchHistoryText = @"搜索历史"; // 搜索历史文本 默认为 @"搜索历史" | ||
NSString *const PYEmptySearchHistoryText = @"清空搜索历史"; // 清空搜索历史文本 默认为 @"清空搜索历史" | ||
NSString *const PYSearchSearchPlaceholderText = @"PYSearchSearchPlaceholderText"; | ||
NSString *const PYSearchHotSearchText = @"PYSearchHotSearchText"; | ||
NSString *const PYSearchSearchHistoryText = @"PYSearchSearchHistoryText"; | ||
NSString *const PYSearchEmptySearchHistoryText = @"PYSearchEmptySearchHistoryText"; | ||
|
||
NSString *const PYSearchEmptyButtonText = @"PYSearchEmptyButtonText"; | ||
NSString *const PYSearchEmptySearchHistoryLogText = @"PYSearchEmptySearchHistoryLogText"; | ||
NSString *const PYSearchCancelButtonText = @"PYSearchCancelButtonText"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+10.2 KB
(130%)
...roj/project.xcworkspace/xcuserdata/iphone5solo.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
1 change: 1 addition & 0 deletions
1
PYSearchExample/PYSearchExample/zh-Hant.lproj/LaunchScreen.strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|