-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented a very unique Localization system. - Dart based CLI generator with isolates for extracting messages. - Auto merging all message files into one json. - Automatic google trnaslation for new messsages. - Automatic generated class based keys for accessing messages. - Implemented provider state solution.
- Loading branch information
Showing
28 changed files
with
1,019 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"DownloadScreen/title": "تحميل", | ||
"HomeScreen/title": "أهلا بك", | ||
"HomeScreen/desc": "استكشاف معهد اليونسكو للإحصاء وضعت بشكل رائع مع رفرفة جوجل صممه المصممين المبدعين.", | ||
"HomeScreen/uiList": "استكشاف معهد اليونسكو للإحصاء", | ||
"HomeScreen/about": "حول التطبيقات", | ||
"HomeScreen/aboutDeveloper": "وشك المطور", | ||
"HomeScreen/download": "تحميل", | ||
"HomeScreen/settings": "الإعدادات", | ||
"HomeScreen/modalWebTitle": "تحذير", | ||
"HomeScreen/modalWebDesc": "رفرفة ليس لديه دعم جيد لشبكة الإنترنت للخروج من مربع. هذا هو السبب في أنك سوف تواجه الخلل والتخلف. لا يوجد شيء خاطئ مع بلدي implementaion بيكوس كل شيء يعمل بشكل جيد على تطبيقات الوطنية.\n\nوذلك لخالية من المتاعب على نحو سلس تجربة فإنني أوصي لكم لتحميل التطبيق الأصلي", | ||
"HomeScreen/modalWebButton1": "تحميل", | ||
"HomeScreen/modalWebButton2": "استمر", | ||
"HomeScreen/modalDesktopTitle": "إنذار", | ||
"HomeScreen/modalDesktopDesc": "في \"BackButton\" بعض الشاشات ليست أفيبل بيكوس انها حققت UI البشعة. لذلك كبديل I نفذت اختصار لوحة المفاتيح لاعادة التنقل.\n\nماك: خيار + مسافة للخلف\nلينكس: البديل + مسافة للخلف\nنوافذ: السيطرة + مسافة للخلف", | ||
"HomeScreen/modalDesktopButton": "استمر", | ||
"HomeScreen/version": "الإصدار", | ||
"HomeScreen/settingsModalTitle": "اختار اللغة", | ||
"HomeScreen/settingsModalEnglish": "الإنجليزية", | ||
"HomeScreen/settingsModalChinese": "صينى", | ||
"HomeScreen/settingsModalArabic": "عربى", | ||
"HomeScreen/settingsModalSystemDefault": "النظام الافتراضي" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"welcome":"Welcome","test":"YUPPP","DownloadScreen/title":"Download","HomeScreen/welcome":"Welcome","HomeScreen/desc":"Explore elegantly crafted UIs with Google's Flutter designed by creative designers.","HomeScreen/title":"Welcome","HomeScreen/uiList":"Explore UIs","HomeScreen/about":"About App","HomeScreen/aboutDeveloper":"About Developer","HomeScreen/download":"Download","HomeScreen/modalWebTitle":"Warning","HomeScreen/modalWebDesc":"Flutter does not have good support for web out of box. That's why you will face bugs and lag. There is nothing wrong with my implementaion becuase every things works well on native apps.\n\nSo for hassle free smooth experience I recommend you to download native app","HomeScreen/modalWebButton1":"Download","HomeScreen/modalWebButton2":"Continue","HomeScreen/ModalDesktopTitle":"Alert","HomeScreen/ModalDesktopDesc":"In some screens 'BackButton' isn't avaible becuase it made UI hideous. So as an alternative I implemented keyboard shortcut to navigate back.\n\nMacOS: Option + Backspace\nLinux: Alt + Backsoace\nWindows: Ctrl + Backspace","HomeScreen/ModalDesktopButton":"Continue","HomeScreen/modalDesktopTitle":"Alert","HomeScreen/modalDesktopDesc":"In some screens 'BackButton' isn't avaible becuase it made UI hideous. So as an alternative I implemented keyboard shortcut to navigate back.\n\nMacOS: Option + Backspace\nLinux: Alt + Backspace\nWindows: Ctrl + Backspace","HomeScreen/modalDesktopButton":"Continue","HomeScreen/version":"VERSION","HomeScreen/settings":"Settings","SettingsScreen/title":"Settings","HomeScreen/settingsModalTitle":"Select Language","HomeScreen/settingsModalEnglish":"english","HomeScreen/settingsModalChinese":"chinese","HomeScreen/settingsModalArabic":"arabic","HomeScreen/settingsModalSystemDefault":"system default"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"DownloadScreen/title":"下载","HomeScreen/title":"欢迎","HomeScreen/desc":"探索与谷歌的扑优雅制作的UI由创意的设计师设计的。","HomeScreen/uiList":"浏览用户界面","HomeScreen/about":"关于应用程序","HomeScreen/aboutDeveloper":"关于开发者","HomeScreen/download":"下载","HomeScreen/settings":"设置","HomeScreen/modalWebTitle":"警告","HomeScreen/modalWebDesc":"扑不具备开箱对网络的良好支持。这就是为什么你会面临漏洞和滞后。有什么错我implementaion监守每一件事上的本地应用效果很好。\n\n因此,对于轻松自由流畅的体验,我建议你下载本机应用程序","HomeScreen/modalWebButton1":"下载","HomeScreen/modalWebButton2":"继续","HomeScreen/modalDesktopTitle":"警报","HomeScreen/modalDesktopDesc":"在某些屏幕“后退按钮”不avaible,原因是其取得UI狰狞。因此,作为一种替代我实现了键盘快捷键,即可返回。\n\nMacOS的:选项+ Backspace键\nLinux的键:Alt + Backspace键\nWindows系统:按Ctrl + Backspace键","HomeScreen/modalDesktopButton":"继续","HomeScreen/version":"版","HomeScreen/settingsModalTitle":"选择语言","HomeScreen/settingsModalEnglish":"英语","HomeScreen/settingsModalChinese":"中文","HomeScreen/settingsModalArabic":"阿拉伯","HomeScreen/settingsModalSystemDefault":"系统默认"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'dart:async'; | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
class AppLocalizations { | ||
AppLocalizations(this.locale); | ||
final Locale locale; | ||
|
||
// Helper method to keep the code in the widgets concise | ||
// Localizations are accessed using an InheritedWidget "of" syntax | ||
static const LocalizationsDelegate<AppLocalizations> delegate = | ||
_AppLocalizationsDelegate(); | ||
|
||
static AppLocalizations of(BuildContext context) { | ||
return Localizations.of<AppLocalizations>(context, AppLocalizations); | ||
} | ||
|
||
Map<String, String> _localizedStrings; | ||
|
||
Future<bool> load() async { | ||
// Load the language JSON file from the "lang" folder | ||
String jsonString = await rootBundle.loadString( | ||
'assets/langs/${locale.languageCode}.json', | ||
); | ||
Map<String, dynamic> jsonMap = json.decode(jsonString); | ||
_localizedStrings = jsonMap.map((key, value) { | ||
return MapEntry(key, value.toString()); | ||
}); | ||
|
||
return true; | ||
} | ||
|
||
// This method will be called from every widget which needs a localized text | ||
String translate(String key) { | ||
return _localizedStrings[key]; | ||
} | ||
} | ||
|
||
// LocalizationsDelegate is a factory for a set of localized resources | ||
// In this case, the localized strings will be gotten in an AppLocalizations object | ||
class _AppLocalizationsDelegate | ||
extends LocalizationsDelegate<AppLocalizations> { | ||
// This delegate instance will never change (it doesn't even have fields!) | ||
// It can provide a constant constructor. | ||
const _AppLocalizationsDelegate(); | ||
|
||
@override | ||
bool isSupported(Locale locale) { | ||
// Include all of your supported language codes here | ||
return ['en', 'zh', 'ar'].contains(locale.languageCode); | ||
} | ||
|
||
@override | ||
Future<AppLocalizations> load(Locale locale) async { | ||
// AppLocalizations class is where the JSON loading actually runs | ||
AppLocalizations localizations = new AppLocalizations(locale); | ||
await localizations.load(); | ||
return localizations; | ||
} | ||
|
||
@override | ||
bool shouldReload(_AppLocalizationsDelegate old) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class AppProvider extends ChangeNotifier { | ||
Locale _activeLocale; | ||
|
||
static List<Locale> locales = [ | ||
Locale('en', 'US'), | ||
Locale('zh', 'CN'), | ||
Locale('ar', 'SA'), | ||
]; | ||
|
||
Locale get activeLocale => this._activeLocale; | ||
|
||
set activeLocale(Locale newLocale) { | ||
this._activeLocale = newLocale; | ||
notifyListeners(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_uis/AppLocalizations.dart'; | ||
|
||
import 'package:flutter_uis/configs/AppDimensions.dart'; | ||
import 'package:flutter_uis/configs/TextStyles.dart'; | ||
|
||
class App { | ||
static BuildContext ctx; | ||
|
||
static init(BuildContext context) { | ||
AppDimensions.init(context); | ||
TextStyles.init(); | ||
App.ctx = context; | ||
} | ||
|
||
static translate(String key) { | ||
return AppLocalizations.of(App.ctx).translate(key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'AppDimensions.dart'; | ||
|
||
abstract class TextStyles { | ||
static TextStyle heading1; | ||
static TextStyle heading2; | ||
|
||
static init() { | ||
// INIT HEADINGS | ||
heading1 = TextStyle( | ||
fontSize: 20 + AppDimensions.ratio * 10, | ||
fontWeight: FontWeight.w700, | ||
); | ||
heading2 = TextStyle( | ||
fontSize: 16 + AppDimensions.ratio * 8, | ||
fontWeight: FontWeight.w600, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This is an auto generated file. Do not make any change on this. | ||
|
||
const scope = 'DownloadScreen'; | ||
|
||
abstract class DownloadScreenMessages { | ||
static String title = '$scope/title'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'dart:isolate'; | ||
|
||
const String scope = 'DownloadScreen'; | ||
|
||
const Map strings = { | ||
'$scope/title': 'Download', | ||
}; | ||
|
||
main(List<String> args, SendPort port) { | ||
port.send({"strings": strings, "scope": scope}); | ||
} |
Oops, something went wrong.