Nour Helmi
Nour Helmi

Reputation: 705

ios Dynamic localization using storyboard localizable string

I have 2 languages in my app, English and Dutch, the point is i want the language to change dynamically, lets say on a button click.

Is there a way to do this without having to write NSLocalizedString(@"key",@"comment") in code ?? i.e: using only storyboard, and somehow make the storyboard refresh it self on button click or something.

Any help will be very much appreciated.

Upvotes: 1

Views: 1521

Answers (3)

Nour Helmi
Nour Helmi

Reputation: 705

I ended up using the LocalizationSystem classes in this link to load the languages i needed when i needed them, i had to bind all the text via code, i'm afraid there's no way around this unfortunately, if you want your language change to be in-app and realtime !!

Thanks all for your help.

Upvotes: 0

wormlxd
wormlxd

Reputation: 514

Use Singleton to Call you Local String.

first to set the language type By you Button;

- (void)setLanguageType:(LanguageType)languageType {
  if (_languageType != languageType) {
      _languageType = languageType;
      [self setBundleForName:bundleForType(languageType)];
      //POST notification if necessary
  }
}

- (void)setBundleForName:(NSString* )name {
  NSString* path = [[ NSBundle mainBundle ] pathForResource:name ofType:@"lproj"];
  _bundle = [NSBundle bundleWithPath:path];
}

and then, Get the string by localizedString.

[[__class sharedInstance] localizedStringForKey:__key];

- (NSString* )localizedStringForKey:(NSString* )key {
  return [_bundle localizedStringForKey:key value:nil table:nil];

}

If you need more help,give me a message.

Upvotes: 3

user3069029
user3069029

Reputation: 211

if you want to create a Custom localization system. Let's try this http://aggressive-mediocrity.blogspot.in/2010/03/custom-localization-system-for-your.html

Upvotes: 2

Related Questions