2

i am newbie here and New to iOS development, i want to get language of Particular country from NSLocale in iOs it i Possible or not? i try this code but it give me all language but i want particular country language

NSArray *test = [NSLocale availableLocaleIdentifiers];
for (int i = 0; i < [test count]; i++) {
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:[test objectAtIndex:i]];
NSString *language = [locale displayNameForKey:NSLocaleIdentifier value:[locale localeIdentifier]];
    NSLog(@"Langaugae %@",language);
}

i mean i want to get All Indian Language and any Other Country Language. Thank You...

iOS Developer
  • 133
  • 3
  • 14
  • your coding is fine what the result u need – Anbu.Karthik Sep 11 '15 at 11:12
  • i need like as if i Select India then Only Indian Language like as Hindi,Tamil,Kannada,kashmiri...etc not any other country Language. – iOS Developer Sep 11 '15 at 11:13
  • i am not sure you can get any single language for this – Anbu.Karthik Sep 11 '15 at 11:47
  • @Anbu.Karthik Here i can't get Only Single language but i got All Language like as spanish,Italian etc... but i Want Language like as as i Select India as my Country then i want only Indian Language not other Country language like as Spanish italian i not want.... – iOS Developer Sep 11 '15 at 12:35

3 Answers3

0
You will have to add localization.string file per language and then add string in key-value pair in that file.

For more detail , you can refer this link.
1.http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014
2.http://smoothlocalize.com/tutorial1.php
3.http://www.ibabbleon.com/iphone_app_localization.html

You can see steps for adding localization file for language in below image screenshot

Hardik Shekhat
  • 1,680
  • 12
  • 21
  • i not need localization for that i already do it for different language i want to get only particular Country language please read my question. – iOS Developer Sep 15 '15 at 17:25
0

Check out http://download.geonames.org/export/dump/readme.txt . They provide lists of geographical information such as countries, languages, cities, locations, etc. In this case, you will need

http://download.geonames.org/export/dump/countryInfo.txt
http://download.geonames.org/export/dump/iso-languagecodes.txt

For India in countryInfo.txt

en-IN,hi,bn,te,mr,ta,ur,gu,kn,ml,or,pa,as,bh,sat,ks,ne,sd,kok,doi,mni,sit,sa,fr,lus,inc 1269750 CN,NP,MM,BT,PK,BD

Searching for hi in the ISO 639-1 column

hin hin hi  Hindi

The list is so large that you might want to import them to sqlite and remove unnecessary columns. I am not sure what you are working on exactly. we might come up with a better solution if you let us know more detail.

keithyip
  • 985
  • 7
  • 21
0
var language = NSLocale.preferredLanguages[0]
print(NSLocale.current.languageCode)

This prints the language code. For example, "en" represents English.

Pang
  • 9,564
  • 146
  • 81
  • 122