Localite

1.0.1

Localite is a lightweight localization package for iOS that simplifies the remote management of strings files.
TelemTobi/Localite

What's New

1.0.1

2023-10-26T15:13:36Z

Localite is a lightweight localization package for iOS that simplifies the remote management of strings files.
It allows you to download and cache localization files from a remote server,
making it easier to keep your app's localization up to date without requiring frequent app updates.


Features

  • Remote fetching and caching of strings files.
  • Efficient version management for localization files.
  • Support for multiple languages.

Installation

Swift Package Manager

You can use Swift Package Manager to integrate Localite into your Xcode project.

In Xcode, go to File > Swift Packages > Add Package Dependency and enter the repository URL:

https://github.com/TelemTobi/Localite.git

Usage

Initialization

Initialize the Localite configuration by setting up your app to use a specific language and providing a URL for the strings file.

import Localite

// Get the first language in user's preferred langauges your app supports
Localite.shared.configure(using: yourStringsFileURL, for: "en", version: 1)

Or, when your app supports only one language:

// Initialize Localite for a single language
Localite.shared.configure(using: yourStringsFileURL)

The file will be cached for offline mode support.


Fetching and Using Strings

Once Localite is configured, you can access localized strings using the standard NSLocalizedString function.
Localite will automatically fetch the strings file from the provided URL, cache it, and use it for localization.

let localizedString = NSLocalizedString("hello_key", comment: "")

Version Management

Localite provides version management for localization files.
When you initialize Localite with a version number, it will only fetch the file if the version is greater than the last fetched version.
If no version is provided, the file will always be fetched.

You can also check the cached version for a specific language:

let cachedVersion = Localite.shared.cachedVersion(for: "en")

Clearing Cache

To clear the Localite cache, including cached strings files and content, use the clearCache method:

Localite.shared.clearCache()

Requirements

  • iOS 11.0+
  • Xcode 12.0+
  • Swift 5.0+

License

Localite is available under the MIT license. See the LICENSE file for more information.


Contributing

We encourage and welcome contributions from the community.
If you'd like to contribute to the development of Localite, please feel free to get involved.
You can start by:

  • Reporting Issues: If you encounter any bugs or have suggestions for improvements, please open an issue.
  • Submitting Pull Requests: If you'd like to contribute code or enhancements, you can submit a pull request. We'll review your contributions and work together to integrate them into the project.

Your involvement is highly appreciated, and it helps make Localite even better. Thank you for considering contributing!

Description

  • Swift Tools 5.4.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Dec 16 2024 13:00:20 GMT-1000 (Hawaii-Aleutian Standard Time)