Skip to content

This is an alternative to NSLocalizedString, although we can override the locale language (i.e. "AppleLanguages" in NSUserDefaults), but for certain situation we might don't want to do that. So I create this.

jslim89/JSLocalizedString

Repository files navigation

JSLocalizedString

Requirements

  • This project is using ARC and tested in iOS 4.3, if your project is using non-ARC, in your project target -> Build Phases -> Compile Sources, add -fobjc-arc to Compiler Flags in JSLocalizedString.m

Install:

  1. Create a file named Localizable.strings in your project.
  2. Go to Project -> Info -> Localizations section, add a new language that you want.
  3. Drag the JSLocalizedString (inside the Libraries folder) to your project.
    • Check the option Copy items into destination group's folder (if needed)
    • Choose Create groups for any added folders
    • Add to project target
  4. Select your file you created just now Localizable.strings, localize it
  5. Under your Supporting Files, edit -Prefix.pch, add #import "JSLocalizedString.h" so that you can use this in whole project (import globally).
  6. You're done.

Usage:

  1. You can set language by calling JSSetLanguage(@"en");, then it will look for the en.lproj folder.
  2. self.navigationItem.title = JSLocalizedString(@"Settings", @"Localized bar title: Settings"); this is similar to NSLocalizedString
  3. You can look the demo project for more info.

Credits:

References:

About

This is an alternative to NSLocalizedString, although we can override the locale language (i.e. "AppleLanguages" in NSUserDefaults), but for certain situation we might don't want to do that. So I create this.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published