Jus*_*nHK 8 xcode nslocalizedstring ios xcode6 swift-playground
有没有办法让本地化的字符串进入iOS游乐场?我有一些从右到左的语言翻译,其中包括我必须使用十六进制编辑器编辑的格式代码(以确保代码的顺序正确),我希望手动检查格式化字符串的输出确保它有效.
另外,是否有任何Mac OS文本编辑器允许您以从左到右的模式显示阿拉伯语和希伯来语?
Swift 3:用于测试本地化的游乐场示例
\n\n//: Playground - noun: a place where people can play\n\nimport UIKit\n\n//current locale identifier\nNSLocale.current.identifier //"en_US"\n\n//available identifiers\nNSLocale.availableLocaleIdentifiers //["eu", "hr_BA", "en_CM", "en_BI" ...]\n\n// particular locales \nlet unitedStatesLocale = NSLocale(localeIdentifier: "en_US") \nlet chinaLocale = NSLocale(localeIdentifier: "zh_Hans") \nlet germanyLocale = NSLocale(localeIdentifier: "de_DE") \nlet indiaLocale = NSLocale(localeIdentifier: "en_IN") \nlet arabicLocale = NSLocale(localeIdentifier: "ar") \nlet hebrewLocale = NSLocale(localeIdentifier: "he") \n\n//called in English\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"English (United States)"\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: chinaLocale.localeIdentifier)! //"Chinese (Simplified)"\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: germanyLocale.localeIdentifier)! //"German (Germany)"\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: indiaLocale.localeIdentifier)! //"English (India)"\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: arabicLocale.localeIdentifier)! //"Arabic"\nunitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: hebrewLocale.localeIdentifier)! //"Hebrew"\n\n//particular locale called in german\ngermanyLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"Englisch (Vereinigte Staaten)"\n\n//particular locale called in arabic\narabicLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"\xd8\xa7\xd9\x84\xd8\xa5\xd9\x86\xd8\xac\xd9\x84\xd9\x8a\xd8\xb2\xd9\x8a\xd8\xa9 (\xd8\xa7\xd9\x84\xd9\x88\xd9\x84\xd8\xa7\xd9\x8a\xd8\xa7\xd8\xaa \xd8\xa7\xd9\x84\xd9\x85\xd8\xaa\xd8\xad\xd8\xaf\xd8\xa9)"\n\n//particular locale called in hebrew\nhebrewLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"\xd7\x90\xd7\xa0\xd7\x92\xd7\x9c\xd7\x99\xd7\xaa (\xd7\x90\xd7\xa8\xd7\xa6\xd7\x95\xd7\xaa \xd7\x94\xd7\x91\xd7\xa8\xd7\x99\xd7\xaa)"\n\n//representing Numbers\nlet pi:NSNumber = 3.14159265358979\nvar numberFormatter = NumberFormatter()\nnumberFormatter.numberStyle = NumberFormatter.Style.decimal\n\n//differences in formatting in various locales \nnumberFormatter.locale = unitedStatesLocale as Locale!\nnumberFormatter.string(from: pi ) //"3.142"\n\nnumberFormatter.locale = chinaLocale as Locale!\nnumberFormatter.string(from: pi ) //"3.142"\n\nnumberFormatter.locale = germanyLocale as Locale!\nnumberFormatter.string(from: pi ) //"3,142"\n\nnumberFormatter.locale = indiaLocale as Locale!\nnumberFormatter.string(from: pi ) //"3.142"\n\nnumberFormatter.locale = arabicLocale as Locale!\nnumberFormatter.string(from: pi ) //"\xd9\xa3\xd9\xab\xd9\xa1\xd9\xa4\xd9\xa2"\n\nnumberFormatter.locale = hebrewLocale as Locale!\nnumberFormatter.string(from: pi ) //"3.142"\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
553 次 |
| 最近记录: |