https://github.com/johnsundell/jslocalization
An Objective-C class that enables dynamic localization of an iOS app.
https://github.com/johnsundell/jslocalization
Last synced: 4 months ago
JSON representation
An Objective-C class that enables dynamic localization of an iOS app.
- Host: GitHub
- URL: https://github.com/johnsundell/jslocalization
- Owner: JohnSundell
- License: mit
- Created: 2013-11-05T21:52:58.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-11-05T22:23:55.000Z (almost 12 years ago)
- Last Synced: 2025-03-16T00:27:01.114Z (7 months ago)
- Language: Objective-C
- Size: 105 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
JSLocalization
==============#### Let your users change the language of your app without restarting it
* Dynamically localize your app, allowing the locale to be changed at runtime.
* Provides APIs for setting the locale, as well as retrieving the localized string for a key, similar to NSLocalizedString.
* Useful when you want to provide an in-app language selection, to allow your users to pick a different language than the system-wide default for your app.#### Here's how to use JSLocalization:
##### Use JSLocalization to obtain your localized strings
```objective-c
myLabel.text = JSLocalizedString(@"MyLabelText");
```##### Use +setCurrentLocale: to change the locale
```objective-c
// Change the locale to Swedish
[JSLocalization setCurrentLocale:@"sv-SE"];
```The parameter passed to +setCurrentLocale: must match the name of a lproj localization bundle available in your app's bundle.
##### Use the JSLocaleDidChangeNotification NSNotification to respond to changes in locale in your views
```objective-c
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localeDidChange:) name:JSLocaleDidChangeNotification object:nil];- (void)localeDidChange:(NSNotification *)notification
{
NSLog(@"Locale changed to: %@", notification.object);// Update label text to match new locale
self.myLabel.text = JSLocalizedString(@"MyLabelText");
}
```#### Hope that you'll enjoy using JSLocalization!
Why not give me a shout on Twitter: [@johnsundell](https://twitter.com/johnsundell)