msayed-net / Localize_and_translate
Licence: mit
Flutter localization in easy steps, really simple
Stars: ✭ 40
Programming Languages
dart
5743 projects
Projects that are alternatives of or similar to Localize and translate
Spider
A small dart library to generate Assets dart code from assets folder.
Stars: ✭ 90 (+125%)
Mutual labels: open-source, library
Amazing Swift Ui 2019
23 Amazing iOS UI Libraries written in Swift for the Past Year (v.2019)
Stars: ✭ 147 (+267.5%)
Mutual labels: open-source, library
Raisincss
An Utility CSS only library. It supports css grid and many more useful css properties.
Stars: ✭ 93 (+132.5%)
Mutual labels: open-source, library
Angular Open Source Starter
This is a starter project for creating open-source libraries for Angular. It is a full fledged Angular workspace with demo application and easy library addition. It is designed to be used for open-sourcing libraries on Github and has everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
Stars: ✭ 120 (+200%)
Mutual labels: open-source, library
Fakeit
The Kotlin fake data generator library!
Stars: ✭ 482 (+1105%)
Mutual labels: open-source, library
Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+2477.5%)
Mutual labels: open-source, library
Redux Unhandled Action
Redux middleware that logs an error to the console when an action is fired and the state is not mutated,
Stars: ✭ 125 (+212.5%)
Mutual labels: open-source, library
Stereo
A Flutter plugin for playing music on iOS and Android.
Stars: ✭ 66 (+65%)
Mutual labels: library, flutter-plugin
Gerador Validador Cpf
Biblioteca JS open-source para gerar e validar CPF.
Stars: ✭ 312 (+680%)
Mutual labels: open-source, library
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (+630%)
Mutual labels: open-source, library
Crawler Commons
A set of reusable Java components that implement functionality common to any web crawler
Stars: ✭ 173 (+332.5%)
Mutual labels: open-source, library
Humblelogging
HumbleLogging is a lightweight C++ logging framework. It aims to be extendible, easy to understand and as fast as possible.
Stars: ✭ 15 (-62.5%)
Mutual labels: open-source, library
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+1547.5%)
Mutual labels: open-source, library
Ml Classify Text Js
Machine learning based text classification in JavaScript using n-grams and cosine similarity
Stars: ✭ 38 (-5%)
Mutual labels: library
Spreed
📞😀 Nextcloud Talk – chat, video & audio calls for Nextcloud
Stars: ✭ 994 (+2385%)
Mutual labels: open-source
Novoda
Common things for all Novoda's open source projects
Stars: ✭ 37 (-7.5%)
Mutual labels: open-source
Freemarker Java 8
Library adding java.time support to FreeMarker
Stars: ✭ 37 (-7.5%)
Mutual labels: open-source
Arcads
ArcAds is a DFP wrapper created by Arc Publishing with publishers in mind.
Stars: ✭ 39 (-2.5%)
Mutual labels: library
Cordova Plugin Inappbrowser
Apache Cordova Plugin inappbrowser
Stars: ✭ 994 (+2385%)
Mutual labels: library
localize_and_translate
Flutter localization in easy steps, really simple
Screenshots
Tutorial
Video
- Arabic : https://www.youtube.com/watch?v=nfDYussovfQ
- English : soon..
Methods
Method | Job |
---|---|
init() |
initialize things, before runApp() |
translate('word') |
word translation |
translate('word',{"key":"value"}) |
word translation with replacement arguments |
setNewLanguage(context,newLanguage:'en',restart: true, remember: true,) |
change language |
isDirectionRTL() |
is Direction RTL check |
currentLanguage |
Active language code |
locale |
Active Locale |
locals() |
Locales list |
delegates |
Localization Delegates |
Installation
- add
.json
translation files as assets
- For example :
'assets/langs/ar.json'
|'assets/langs/en.json'
- structure should look like
{
"appTitle": "تطبيق تجريبى",
"buttonTitle": "English",
"googleTest": "تجربة ترجمة جوجل",
"textArea": "هذا مجرد نموذج للتأكد من اداء الأداة"
}
- define them as assets in pubspec.yaml
flutter:
assets:
- assets/langs/en.json
- assets/langs/ar.json
Migrate from 2.x.x to 3.x.x
- Replace
LIST_OF_LANGS = ['ar', 'en'];
LANGS_DIR = 'assets/langs/';
await translator.init();
- With
await translator.init(
localeDefault: LocalizationDefaultType.device,
languagesList: <String>['ar', 'en'],
assetsDirectory: 'assets/langs/',
apiKeyGoogle: '<Key>', // NOT YET TESTED
);
Initialization
- Add imports to main.dart
- Make
main()
async
and do the following - Ensure flutter activated
WidgetsFlutterBinding.ensureInitialized()
- Initialize
await translator.init();
with neccassry parameters - Inside
runApp()
wrap entry class withLocalizedApp()
- Note : make sure you define it's child into different place "NOT INSIDE"
import 'package:flutter/material.dart';
import 'package:localize_and_translate/localize_and_translate.dart';
main() async {
// if your flutter > 1.7.8 : ensure flutter activated
WidgetsFlutterBinding.ensureInitialized();
await translator.init(
localeDefault: LocalizationDefaultType.device,
languagesList: <String>['ar', 'en'],
assetsDirectory: 'assets/langs/',
apiKeyGoogle: '<Key>', // NOT YET TESTED
);
runApp(
LocalizedApp(
child: MyApp(),
),
);
}
-
LocalizedApp()
child example ->MaterialApp()
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
localizationsDelegates: translator.delegates, // Android + iOS Delegates
locale: translator.locale, // Active locale
supportedLocales: translator.locals(), // Locals list
);
}
}
Usage
- use
translate("appTitle")
- use
googleTranslate("test", from: 'en', to: 'ar')
- use
setNewLanguage(context, newLanguage: 'ar', remember: true, restart: true);
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(),
appBar: AppBar(
title: Text(translator.translate('appTitle')),
// centerTitle: true,
),
body: Container(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
SizedBox(height: 50),
Text(
translator.translate('textArea'),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 35),
),
OutlineButton(
onPressed: () {
translator.setNewLanguage(
context,
newLanguage: translator.currentLanguage == 'ar' ? 'en' : 'ar',
remember: true,
restart: true,
);
},
child: Text(translator.translate('buttonTitle')),
),
OutlineButton(
onPressed: () async {
print(await translator.translateWithGoogle(
key: 'رجل',
from: 'ar',
));
},
child: Text(translator.translate('googleTest')),
),
],
),
),
);
}
}
Show some ❤️ and star the repo
Project Created & Maintained By
Software Engineer | In ❤️ with Flutter
Note : All Contibutions Are Welcomed
Contributions
-
translate()
accept keys : by mo-ah-dawood - Change template from plugin to package : by mo-ah-dawood
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].