2016-03-11 13 views
5

क्या आईओएस खेल के मैदान में स्थानीय तारों को पाने का कोई तरीका है? मेरे पास कई दाएं-बाएं भाषा अनुवाद हैं जिनमें प्रारूप कोड शामिल हैं जिन्हें मुझे हेक्स संपादक के साथ संपादित करना था (यह सुनिश्चित करने के लिए कि कोड सही बाइट ऑर्डर में थे), और मैं मैन्युअल रूप से स्वरूपित स्ट्रिंग के आउटपुट की जांच करना चाहता हूं यह सुनिश्चित करने के लिए कि यह काम किया।आईओएस खेल के मैदान में स्थानीयकरण का परीक्षण

एक तरफ के रूप में, क्या कोई मैक ओएस टेक्स्ट एडिटर है जो आपको बाएं से दाएं मोड में अरबी और हिब्रू प्रदर्शित करने की अनुमति देता है?

उत्तर

0

स्विफ्ट 3: परीक्षण स्थानीयकरणों के लिए खेल का मैदान उदाहरण

//: Playground - noun: a place where people can play 

import UIKit 

//current locale identifier 
NSLocale.current.identifier //"en_US" 

//available identifiers 
NSLocale.availableLocaleIdentifiers //["eu", "hr_BA", "en_CM", "en_BI" ...] 

// particular locales  
let unitedStatesLocale = NSLocale(localeIdentifier: "en_US") 
let chinaLocale = NSLocale(localeIdentifier: "zh_Hans") 
let germanyLocale = NSLocale(localeIdentifier: "de_DE") 
let indiaLocale = NSLocale(localeIdentifier: "en_IN") 
let arabicLocale = NSLocale(localeIdentifier: "ar") 
let hebrewLocale = NSLocale(localeIdentifier: "he") 

//called in English 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"English (United States)" 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: chinaLocale.localeIdentifier)! //"Chinese (Simplified)" 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: germanyLocale.localeIdentifier)! //"German (Germany)" 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: indiaLocale.localeIdentifier)! //"English (India)" 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: arabicLocale.localeIdentifier)! //"Arabic" 
unitedStatesLocale.displayName(forKey: NSLocale.Key.identifier, value: hebrewLocale.localeIdentifier)! //"Hebrew" 

//particular locale called in german 
germanyLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"Englisch (Vereinigte Staaten)" 

//particular locale called in arabic 
arabicLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"الإنجليزية (الولايات المتحدة)" 

//particular locale called in hebrew 
hebrewLocale.displayName(forKey: NSLocale.Key.identifier, value: unitedStatesLocale.localeIdentifier)! //"אנגלית (ארצות הברית)" 

//representing Numbers 
let pi:NSNumber = 3.14159265358979 
var numberFormatter = NumberFormatter() 
numberFormatter.numberStyle = NumberFormatter.Style.decimal 

//differences in formatting in various locales 
numberFormatter.locale = unitedStatesLocale as Locale! 
numberFormatter.string(from: pi) //"3.142" 

numberFormatter.locale = chinaLocale as Locale! 
numberFormatter.string(from: pi) //"3.142" 

numberFormatter.locale = germanyLocale as Locale! 
numberFormatter.string(from: pi) //"3,142" 

numberFormatter.locale = indiaLocale as Locale! 
numberFormatter.string(from: pi) //"3.142" 

numberFormatter.locale = arabicLocale as Locale! 
numberFormatter.string(from: pi) //"٣٫١٤٢" 

numberFormatter.locale = hebrewLocale as Locale! 
numberFormatter.string(from: pi) //"3.142" 
+0

उत्तर के लिए धन्यवाद - मैं वास्तव में एक तरह से अपने आवेदन की स्ट्रिंग फ़ाइलों का उपयोग करने के लिए देख रहा था, हालांकि, कई स्थानों में एक भी स्ट्रिंग मुद्रित करने के लिए नहीं । – JustinHK

संबंधित मुद्दे