An Offline tool for Localizations using Excel files.
offline_localization
is a simple localization package for Flutter applications that allows you to
manage translations offline using Excel files. It provides an easy-to-use interface for
initializing, changing, and retrieving translations in multiple languages.
- Offline Localization: Read and manage translations directly from Excel files stored locally in the assets folder.
- Simple Integration: Initialize the localization with a single line of code and change the locale effortlessly.
- Efficient Retrieval: Retrieve translations using a key and the current language, handling fallbacks gracefully.
To use this package, add offline_localization
as a dependency in your pubspec.yaml
file:
dependencies:
offline_localization: ^1.0.2
import 'package:offline_localization/offline_localization.dart';
void main() async {
// Replace 'assets/translations.xlsx' with the path to your Excel file
final excelFilePath = 'assets/translations.xlsx';
// Replace 'en' with the default language in your Excel file
final defaultLanguage = 'en';
await Loc.initialize(excelFilePath, defaultLanguage);
// Your app code...
}
// Change the current language to 'fr'
await Loc.changeLocale("assets/translations.xlsx",'fr');
// Get the translation for the key 'hello_key'
String translation = Loc.get('hello_key');
See the example directory for a sample Flutter application using offline_localization
.
This package assumes that the Excel file follows a specific format, with keys in the first column and languages in subsequent columns. Make sure your Excel file is structured accordingly.
keys | lang1 | lang2 | lang3 |
---|---|---|---|
hello_key | Hello in Lang 1 | Hello in Lang2 | Hello in Lang 3 |
other_key | Other in Lang 1 | Other in Lang2 | Other in Lang 3 |
Please file issues to send feedback or report a bug. Thank you!
This project is licensed under the MIT License - see the LICENSE file for details.