About ESLocale
ESLocale is a comprehensive library for localizing iOS apps, allowing developers to easily handle various aspects of internationalization. With ESLocale, you can effortlessly support different languages, regional formats, and cultural conventions in your app.
Key Features
- Localized translations for multiple languages.
- Support for dynamic language switching.
- Localized number, date, and time formatting.
- Localization of currencies, units, and measurements.
- Localized pluralization and grammatical rules.
Installation
ESLocale can be easily integrated into your iOS project via CocoaPods. Follow these simple steps to install ESLocale:
- Open your project’s directory in Terminal.
- Create a
Podfile
by running the commandpod init
. - Add the following line to your
Podfile
:
pod 'ESLocale'
- Save the
Podfile
and runpod install
. - Open the newly created
.xcworkspace
file. - You can now import ESLocale library in your code and start using it.
Usage
ESLocale provides a straightforward API to fulfill all your localization requirements. Here’s an overview:
Localizing Strings
1. Add a file named Localizable.strings
to your project’s main bundle.
2. Create language-specific versions of the file for each supported language using .strings
file format. For example, Localizable.strings
(English) and Localizable.strings (es)
(Spanish).
3. In your Swift code, use the ESLocale
class to retrieve localized strings. For example:
let localizedString = ESLocale.localizedString(forKey: "hello_world")
Localized Formatting
ESLocale supports localized formatting for numbers, dates, times, currencies, units, and measurements.
Here are a few examples:
let number = 12345.6789 let formattedNumber = ESLocale.localizedString(forNumber: number) let date = Date() let formattedDate = ESLocale.localizedString(forDate: date) let currencyValue = 99.99 let currencyCode = "USD" let formattedCurrency = ESLocale.localizedString(forCurrencyValue: currencyValue, withCurrencyCode: currencyCode)
Dynamic Language Switching
With ESLocale, you can support dynamic language switching within your app.
To change the current language, use the following code:
ESLocale.currentLanguage = "fr"
The appropriate localized resources will be automatically loaded for the selected language.
Pluralization and Grammatical Rules
ESLocale provides support for localized pluralization and grammatical rules. Here’s an example:
let applesCount = 5 let localizedString = ESLocale.localizedString(forKey: "apple_count", withPluralization: true, variables: ["count": applesCount])
In this example, the appropriate localized string for the key "apple_count"
will be selected based on the value of the "count"
variable.
Documentation & Resources
For detailed information about using ESLocale and implementing localization in your iOS app, refer to the following resources:
Community & Support
For community support and discussions, please visit our official forum or GitHub repository:
License
ESLocale is released under the MIT License. For more details, see the LICENSE file included with the library.
Β© 2021 ESLocale. All rights reserved.