• Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The ios-i18n library provides seamless integration of plurals into iOS 6 apps.

Smartling.i18n.framework

iOS 6+ Plurals Localization Library

Note: this library was designed to support plurals in iOS 6. As of iOS 7, Apple added support for plurals via string dictionaries. New projects should use Apple’s native plural support. This library has been deprecated.

iOS (pre-iOS 7) localization did not support plural functionality out of the box. The ios-i18n library was designed to bridge that gap and provide a means for developers to seamlessly integrate plurals into their localized apps across any number of locales.

As of iOS 7 and Mac OS X 10.9 Mavericks, Foundation has the ability to specify localized strings according to pluralization and grammar rules. You can find more about this in the Handling Noun Plurals and Units of Measurement section of the Internationalization and Localization Guide.

ios-i18n is not compatible with Apple's implementation, and does not handle new ".stringsdict" resource files.

Installation

Via CocoaPods

Update your Podfile with

pod 'Smartling.i18n', '~> 1.0'

Framework bundle

  1. Download [Smartling.i18n.framework.tar.gz] fw
  2. Unpack and drag Smartling.i18n.framework to your project's Frameworks group.
  3. In the Build Settings of your target add -ObjC to Other Linker Flags.
  4. #import <Smartling.i18n/SLLocalization.h>

Carthage

Carthage compatible

Cartfile

github "Smartling/ios-i18n"

Usage

Plurals

int number = 42;
NSString *format = SLPluralizedString(@"%d apples", number, @"Comment");
NSString *text = [NSString stringWithFormat:format, number];

SLPluralizedString...

There are four functions to retrieve pluralized string, similar to NSLocalizedString:

NSString * SLPluralizedString(NSString *key, number, NSString *comment)
NSString * SLPluralizedStringFromTable(NSString *key,
    NSString *tableName,
    number,
    NSString *comment)
NSString * SLPluralizedStringFromTableInBundle(NSString *key,
    NSString *tableName,
    NSBundle *bundle,
    number,
    NSString *comment)
NSString * SLPluralizedStringWithDefaultValue(NSString *key,
    NSString *tableName,
    NSBundle *bundle,
    number,
    NSString *defaultValue,
    NSString *comment)

number can be any primitive type (int, long, float, double), or NSNumber.

Notes

Base internationalization

When using Base internationalization, Localizable.strings files should be in language-specific folders (like en.lproj), not in Base.lproj folder.

Fallback

ios-i18n implements resource fallback for each key query. At runtime, SLPluralizedString retrieves string whose localization most closely matches the preferred language of the user.

In contrast, Apple's implementation of NSLocalizedString first selects appropriate localization table, then uses this table for all subsequent queries. For more details on this mechanism, see [Support for Internationalization] applei18n

Extended .strings format

ios-i18n extends standard .strings file format with pluralized variants.

The extended syntax for key is: KEY##{rule}. Where KEY is the original key string, and rule is one of plural rules: zero, one, two, few, many, other.

The rule portion of the full key conforms to the CLDR spec on plural forms. The ios-i18n library will load a particular translation following the same rules as defined under CLDR.

Sample resource files for key string %d songs found:

en.lproj/Localizable.strings
/* Number of songs from search results */
"%d songs found##{one}" = "One song found";
"%d songs found##{other}" = "%d songs found";
ru.lproj/Localizable.strings
/* Number of songs from search results */
"%d songs found##{one}" = "Найдена %d песня";
"%d songs found##{few}" = "Найдено %d песни";
"%d songs found##{many}" = "Найдено %d песен";
"%d songs found##{other}" = "Найдено %d песен";

Copyright and license

Copyright 2013 Smartling, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

keycloak-user-migration-provider

Provides a Keycloak user federation provider for migrating users from a legacy system to Keycloak with zero downtime.
Java
92
star
2

aws-terraform-workshops

HCL
61
star
3

smartling-keycloak-extras

Provides projects that may be useful when implementing Spring Security with Keycloak.
Java
25
star
4

api-sdk-python

SDK for integrating with the Smartling API. The Smartling API allows developers to upload language specific resource files and download the translations of those files for easy integration within their application.
Python
14
star
5

api-sdk-java

This SDK is no longer maintained and is superceeded by Smartling's java-api-sdk.
Java
13
star
6

api-sdk-ruby

SDK for integrating with the Smartling API. The Smartling API allows developers to upload language specific resource files and download the translations of those files for easy integration within their application.
Ruby
13
star
7

marketo-rest-sdk-java

Java API for Marketo Assets REST API
Java
9
star
8

api-scripts

Shell
6
star
9

hubspot-rest-sdk-java

Java API for HubSpot REST API
Java
6
star
10

api-sdk-php

SDK for integrating with the Smartling API. The Smartling API allows developers to upload language specific resource files and download the translations of those files for easy integration within their application. http://docs.smartling.com
PHP
6
star
11

android-repository

Maven repository for binary Android SDKs
5
star
12

eloqua-rest-sdk-java

Java API for Eloqua REST API
Java
4
star
13

java-api-sdk

SDK for integrating with the Smartling API.
Java
3
star
14

api-docs

Smartling OpenAPI Specifications
JavaScript
3
star
15

api-sdk-nodejs

TypeScript
3
star
16

ios-lqa-sdk

Smartling Mobile SDK for iOS (Mobile Context, In App Review, Mobile Delivery Network)
Objective-C
3
star
17

api-sdk-go

Go
2
star
18

dd-better-mysql-dashboard

2
star
19

wordpress-localization-plugin

Wordpress plugin to seamlessly translate your content for localization
PHP
2
star
20

smartling-samples

Python
1
star
21

ios-context-framework

Captures context from native iOS applications into Smartling TMS
Ruby
1
star
22

sfmc-rest-sdk-java

SDK for Salesforce Marketing Cloud (ExactTarget) API
Java
1
star
23

dynamo-backup-pipeline

Terraform module to backup dynamo table
HCL
1
star
24

ml-text

Smartling Text Classifier Library
Java
1
star
25

wordpress-divi-builder-localization-plugin

Add localization support for WordPress Divi Page Builder
PHP
1
star
26

api-sdk-net

.Net SDK for integrating with the Smartling API. The Smartling API allows developers to upload language specific resource files and download the translations of those files for easy integration within their application. http://docs.smartling.com
C#
1
star