1 typedef enum LanguageType 2 { 3 kLanguageEnglish = 0, 4 kLanguageChinese, 5 kLanguageFrench, 6 kLanguageItalian, 7 kLanguageGerman, 8 kLanguageSpanish, 9 kLanguageRussian 10 } ccLanguageType; 11 12 13 14 15 ccLanguageType CCApplication::getCurrentLanguage() 16 { 17 // get the current language and country config 18 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 19 NSArray *languages = [defaults objectForKey: @" AppleLanguages "]; 20 NSString *currentLanguage = [languages objectAtIndex: 0]; 21 22 // get the current language code.(such as English is "en", Chinese is "zh" and so on) 23 NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; 24 NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; 25 26 ccLanguageType ret = kLanguageEnglish; 27 if ([languageCode isEqualToString: @" zh "]) 28 { 29 ret = kLanguageChinese; 30 } 31 else if ([languageCode isEqualToString: @" en "]) 32 { 33 ret = kLanguageEnglish; 34 } 35 else if ([languageCode isEqualToString: @" fr "]){ 36 ret = kLanguageFrench; 37 } 38 else if ([languageCode isEqualToString: @" it "]){ 39 ret = kLanguageItalian; 40 } 41 else if ([languageCode isEqualToString: @" de "]){ 42 ret = kLanguageGerman; 43 } 44 else if ([languageCode isEqualToString: @" es "]){ 45 ret = kLanguageSpanish; 46 } 47 else if ([languageCode isEqualToString: @" ru "]){ 48 ret = kLanguageRussian; 49 } 50 51 return ret; 52 }