title: iPhone - Custom language setup
body: <p>In my application, users can choose a language, so I would like my app to change the language accordingly, but it doesn't work. I have found this code online:</p>
  
  <pre><code>// Force languages
  NSString * lang=[[NSUserDefaults standardUserDefaults] stringForKey:@"idioma"];
  NSLog(@"language %@",[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleLanguages"]);
  if ([lang isEqualToString:@"castella"]) {
  
      [[NSUserDefaults standardUserDefaults]
       setObject:[NSArray arrayWithObject:@"es"]
       forKey:@"AppleLanguages"];
  } //else just default user lang
  </code></pre>
  
  <p>This code doesn't work. I think I am just setting up another preference setting. I really want to modify the locale. I have some strings that are localized and also some of the <a href="http://en.wikipedia.org/wiki/Interface_Builder" rel="nofollow">NIB</a> files, so I would like to add the Spanish to prefered locales list on the first position, but I don't really understand how to do that.</p>
  
  <p>In the settings for the application, I have an option to chose the language. That is not just out of my stubborness; it is just that regional laguages are important here and sometimes the <a href="http://en.wikipedia.org/wiki/IPhone" rel="nofollow">iPhone</a> doesn't provide support for them, but I pronvide the translations.</p>
  
  <hr/>
  
  <p>From the answers I decided to give up messing with the locale, but would it be possible to show a different <a href="http://en.wikipedia.org/wiki/Interface_Builder" rel="nofollow">NIB</a> file (from en.proj or es.proj)? I already have the first part:</p>
  
  <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
          // Custom initialization
          NSString * lang=[[NSUserDefaults standardUserDefaults] stringForKey:@"idioma"];
  
          if ([lang isEqualToString:@"castella"]) {
              //Load NIB filer from "es.proj".
          }
      }
      return self;
  }
  </code></pre>
  
  <p>Is that even possible?</p>