2

I'm localizing my app which is cocos2d so there are no nib files, I'm localizing a label which is fine but want to check the device language to set an exact font and font size for each language. In short I want to do it as the following:

If (device.language == en) {
Set font to "fontname" and "fontsize" to x;
} else {
set it to "another font name" and font size to y;
}

How to check that the device language/settings is set to an exact language?

XIII
  • 2,036
  • 16
  • 25

1 Answers1

5

You can use:

[[NSLocale preferredLanguages] objectAtIndex:0]

This will return a language tag like “en” or “ja”.

adambinsz
  • 235
  • 1
  • 7
  • Thanks a lot, exactly what I wanted – XIII Jun 05 '12 at 14:28
  • This is not true, in Apple documentation there is a note about that method: `// note that this list does not indicate what language the app is actually running in; the [NSBundle mainBundle] object determines that at launch and knows that information` – Bartłomiej Semańczyk Jan 10 '16 at 14:59