首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏编程语言

    Swift:NSLocalizedString 国际化语言配置

    5.项目中使用: let str = NSLocalizedString("test", comment: "") print(str) 以上就是配置流程 如果你没有用上面的文件名创建 记得在读取的时候填写对应参数 /// Returns a localized string, using the main bundle if one is not specified. public func NSLocalizedString

    3.4K20发布于 2019-11-03
  • 来自专栏学海无涯

    iOS14开发- 国际化

    Dialog"; "btnTitle" = "Cancel"; "title" = "温馨提示"; "message" = "这是一个对话框"; "btnTitle" = "取消"; 在需要的地方使用NSLocalizedString NSLocalizedString("title", comment: "") NSLocalizedString("message", comment: "") NSLocalizedString(" btnTitle", comment: "") 图片国际化 图片和文本国际化的使用方式一样,首先在Localizable.strings中进行图片名称的设置,然后通过NSLocalizedString( let imageName = NSLocalizedString("img", comment: "") let image = UIImage(named: imageName) imageView.image

    96220发布于 2021-11-24
  • 来自专栏三掌柜的技术空间

    iOS开发:实现点击常用控件弹出地区选择框(万能方法)

    alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; NSString *generalV = NSLocalizedString (@"General Version", nil); NSString *America = NSLocalizedString(@"United States", nil); NSString *France = NSLocalizedString(@"France", nil); NSString *China = NSLocalizedString(@"China", nil); NSString *Japan = NSLocalizedString(@"Japan", nil); NSString *Taiwan = NSLocalizedString(@"Taiwan changeRegion = array[i]; [self.tableView reloadData]; }]]; } NSString *cancel = NSLocalizedString

    2.3K32编辑于 2021-12-15
  • 来自专栏c#开发者

    自定义ios keyboard tool bar代码片段

    UIBarStyleBlackTranslucent; UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString handleActionBarDone:)]; _prevNext = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:NSLocalizedString (@"Previous", @""), NSLocalizedString(@"Next", @""), nil]]; _prevNext.momentary = YES; _prevNext.segmentedControlStyle

    57860发布于 2018-04-12
  • 来自专栏万岳科技那些事儿

    在线教育平台开发中,教学白板是如何实现的

    } else { UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString 禁止用户的教具操作 ture为禁止 [_room disableDeviceInputs:YES]; } else { self.title = NSLocalizedString @"加入失败", nil); UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString

    1.5K20发布于 2020-06-04
  • 来自专栏iOS逆向与安全

    iOS小技能:本地化(Internationalization & Localization)

    BPInternational/Introduction/Introduction.html#//apple_ref/doc/uid/10000171i I 本地化 开发规范:始终把面向用户的字符串用 NSLocalizedString genstrings ViewController.m genstrings苹果推出的一个用于自动从代码的NSLocalizedString提取生成国际化字符串的工具,genstrings 会浏览每个所选的源文件 ,以及每个使用 NSLocalizedString 的源文件,把键和注释追加到目标文件。 在运行时,NSLocalizedString 会确定首选的语言,并在应用程序包中找到相应的 Localizable.strings 文件,例如法语文件fr.lproj/Localizable.strings #define NSLocalizedString(key, comment) \ [NSBundle.mainBundle localizedStringForKey:(key) value

    4K30编辑于 2022-08-22
  • 来自专栏iOS Developer

    iOS开发内购全套图文教程

    UIAlertView alloc] initWithTitle:@"提示" message:@"您的手机没有打开程序内付费购买" delegate:nil cancelButtonTitle:NSLocalizedString NSLog(@"-------弹出错误信息----------"); UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:NSLocalizedString (@"Alert",NULL) message:[error localizedDescription] delegate:nil cancelButtonTitle:NSLocalizedString UIAlertView alloc] initWithTitle:@"" message:@"购买成功" delegate:nil cancelButtonTitle:NSLocalizedString initWithTitle:@"提示" message:@"购买失败,请重新尝试购买" delegate:nil cancelButtonTitle:NSLocalizedString

    1.2K60发布于 2018-06-28
  • 来自专栏全栈程序员必看

    Swift如何给应用添加3D Touch菜单

    UIApplicationShortcutIcon(type: .confirmation) let firstItem = UIMutableApplicationShortcutItem(type: "1", localizedTitle: NSLocalizedString (type: .taskCompleted) let firstItem1 = UIMutableApplicationShortcutItem(type: "2", localizedTitle: NSLocalizedString UIApplicationShortcutIcon(type: .task) let firstItem2 = UIMutableApplicationShortcutItem(type: "3", localizedTitle: NSLocalizedString UIApplicationShortcutIcon(type: .add) let firstItem3 = UIMutableApplicationShortcutItem(type: "4", localizedTitle: NSLocalizedString

    1.4K20发布于 2021-05-31
  • 来自专栏王大锤

    swift3.0之后的Error处理

    { switch self { case .forgotten: return NSLocalizedString("I forgot it") case .lost: return NSLocalizedString("I lost it") case .dogAteIt: return NSLocalizedString("The dog ate it") }

    1.5K50发布于 2018-05-17
  • 来自专栏BY的专栏

    在 Swift 中使用 IBInspectable前言正文结语

    { set { guard let newValue = newValue else { return } text = NSLocalizedString { set { guard let newValue = newValue else { return } setTitle(NSLocalizedString { set { guard let newValue = newValue else { return } placeholder = NSLocalizedString

    1.2K40发布于 2018-05-11
  • 来自专栏iOS逆向与安全

    iOS APP 内的本地化切换【修订】

    在这里插入图片描述 在代码中使用NSLocalizedString(key, comment)来读取本地化字符串,key是Localizable.strings文件中等号左边的字符串,comment纯粹是注释 #define NSLocalizedString(key, comment) \ [NSBundle.mainBundle localizedStringForKey:(key) value NSString *)table { //假如为跟随系统 if (self.languageType==HZLanguageTypeSystem) { return NSLocalizedString (@"cancel") cancleBlock:nil sureString:QCTLocal(@"sure") sureBlock:^{ 如果没有对字符串进行本地化 或者 找不到key对应的值,NSLocalizedString

    94520发布于 2021-07-05
  • 来自专栏全栈程序员必看

    IOS开展:导航中添加多个button并加入左侧logo

    ,我是全栈君 添加多个button,同样只能加入一个 UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString registerClick:)]; UIBarButtonItem *anotherButton2 = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString

    73610编辑于 2022-07-06
  • 来自专栏iOS逆向与安全

    iOS小技能:APP内的本地化语言切换(案例:登录界面切换中英文)

    Tip"="Tip"; zh-Hans.lproj/Localizable.strings "Connected" = "已连接"; "Tip"="提示"; 在这里插入图片描述 在代码中使用NSLocalizedString (key, comment)来读取本地化字符串,key是Localizable.strings文件中等号左边的字符串,comment纯粹是注释 #define NSLocalizedString(key NSString *)table { //假如为跟随系统 if (self.languageType==HZLanguageTypeSystem) { return NSLocalizedString (@"cancel") cancleBlock:nil sureString:QCTLocal(@"sure") sureBlock:^{ 如果没有对字符串进行本地化 或者 找不到key对应的值,NSLocalizedString NSString *)table { //假如为跟随系统 if (self.languageType==HZLanguageTypeSystem) { return NSLocalizedString

    3.8K20编辑于 2022-08-22
  • 来自专栏三掌柜的技术空间

    iOS开发:Block传值的运用

    *timeValue = dic[@"Time"];         NSString *waterValue = dic[@"Water"];         NSString *title = NSLocalizedString (@"Title", nil);         NSString *bluetooth = NSLocalizedString(@"Choose Success!" , nil);         NSString *confirm = NSLocalizedString(@"Confirm", nil);         UIAlertController *alert

    1.1K41编辑于 2021-12-02
  • 来自专栏TechBox

    3分钟实现iOS语言本地化/国际化(图文详解)

    Snip20160619_15.png 我们只需要使用Foundation框架自带的NSLocalizedString(key, comment)这个宏根据Key获取对应的字符串,然后赋值给代码中的字符串 #define NSLocalizedString(key, comment) [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" 但是上面介绍的代码中字符串的本地化是使用的是默认的文件名"Localizable",因为启动程序时,系统将根据语言加载相应的文件得到其对应的字符串文件,这个字符串可以通过系统将NSLocalizedString (四)图片本地化 本地化图片,有两种方式,第一种方式和本地化代码中的字符串一样,通过NSLocalizedString(key,comment)来获取相应的字符串,然后根据这个字符串再获取图片。 方式一 NSString *imageName = NSLocalizedString(@"icon", nil); UIImage *image = [UIImage imageNamed:imageName

    19.3K31发布于 2018-06-05
  • 来自专栏iOS逆向与安全

    iOS字符串的本地化(APP 内的本地化切换) 、nib本地化、图片本地化

    NSString *)table { //假如为跟随系统 if (self.languageType==HZLanguageTypeSystem) { return NSLocalizedString -s substring substitute 'substring' for NSLocalizedString. the genstrings(1) man page for full documentation 生成字符串资源文件的另一种方式(通过终端命令genstrings) 苹果推出的一个用于自动从代码的NSLocalizedString key, tbl, comment)来获取字符串,资源文件会以tbl参数作为文件名 使用步骤: 首先添加获取字符串的代码,比如在ViewController.m NSString *tip = NSLocalizedString (@"Tip", @"dialog title"); NSString *ok = NSLocalizedString(@"Ok", @"dialog button"); NSString

    2.2K30发布于 2021-07-05
  • 来自专栏iOS开发攻城狮的集散地

    iOS app国际化 、跳转到系统设置、iOS10通知、正则表达式

    文件里面主要存的是配置文件信息的不同语言键值对,如“CFBundleDisplayName”是APP的名字;Localizable.strings主要存的是自定义的一些字符串;(本人自己的理解,欢迎指教) //NSLocalizedString NSLocalizedStringFromTable(<#key#>, <#tbl#>, <#comment#>)文件名不为Localizable时取字符串的方法 NSString * string = NSLocalizedString

    86040发布于 2018-05-22
  • 来自专栏代码散人

    如何优雅的完成iOS国际化

    : let numberOfPeople = 1 let numberOfCmoputer = 10 let text = NSString.localizedStringWithFormat(NSLocalizedString 当然要记得代码里需要国际化的字符串使用NSLocalizedString 或者 [NSString localizedStringWithFormat...]

    2.4K30发布于 2019-02-26
  • 来自专栏肘子的Swift记事本

    对iOS应用中的文本进行本地化

    为了能够更精确的对本地化后的文本进行排序,我们也可以对Drink的比较函数做近一步修改: //将lhs.name < rhs.name//改为NSLocalizedString(lhs.name,comment : "") < NSLocalizedString(rhs.name,comment: "") NSLocalizedString可以通过给定的文本键获取对应后的文本值 将InfoView中的 var list:String { order.list.map(\.drink.name).joined(separator: " ")} 改为: order.list.map{NSLocalizedString name: String, price: Double, calories: Double) { self.name = String.localizedStringWithFormat(NSLocalizedString var list:String { order.list.map{NSLocalizedString($0.drink.name, comment: "")}.formatted(.list

    3.3K20编辑于 2022-07-28
  • 来自专栏月亮与二进制

    iOS本地化国际化多语言支持

    现在,我们在storyboard中向视图里添加两个Label,一个用于说明,一个用来显示不同的语言: 将用来显示不同语言的Label关联到代码里去,然后在代码里设置Label所显示的内容: // 使用NSLocalizedString Localization文件中设置的内容实现本地化 // 第一个参数是要显示的内容对应的key值,第二个参数是注释,暂时没发现有什么用 self.locallizedLabel.text = NSLocalizedString (@"LabelText", nil); 如注释所说,这里用到了NSLocalizedString这个方法,这个方法就是用来关联我们刚才创建的Localizable.strings文件的,如果文件名错了

    1.1K10发布于 2021-11-23
领券