Coder Social home page Coder Social logo

example_localization's Introduction

Example_Localization

Example iOS application in Swift to demonstrate how to properly use Strings and StringsDict files to achieve localization.

Basic Localization

Localizing strings is fairly straightforward. Strings files are used for this. Each localized string in a Strings file is represented by a key-value pair. Each locale supported in the application has it's own Strings file. The key of the key-value pair is consistent across locales and Strings files. The value of the key-value pair is the actual "display" value which is localized in the locale of the String file. At run time, the locale or language of the device dictates which Strings file is used when an NSLocalizedString with a provided key is intialized.

Strings files support parameterization via String Format Specifiers.

Examples

Acceptable values in Strings files include:

  • "OK"
  • "Hello World!"
  • "Hello %@" where "%@" is a name.

Unacceptable values in Strings files include:

  • "Found %d matches in your area!"
  • "Found %d match in your area!"

You should NOT use Strings files for translations that have pluralization. You'll use StringsDict for these cases.

Pluralized Localization

Localizing strings with pluralization is a little more complex. StringsDict files are used for this. Similar to Strings files, each locale or language the application supports should have its own StringsDict file. Again, at run time, the locale or language of the device dictates which StringsDict file is used when an NSLocalizedString with a provided key is intialized. In general, you should follow this cheat-sheet for the basic setup of a StringsDict file.

StringsDict Cheat Sheet

Helpful links:

Screenshots

English

English Example 1 English Example 2 English Example 3
English Example 1 English Example 2 English Example 3

Spanish

Spanish Example 1 Spanish Example 2 Spanish Example 3
Spanish Example 1 Spanish Example 2 Spanish Example 3

example_localization's People

Contributors

cameroneubank avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.