nations 0.0.1
nations: ^0.0.1 copied to clipboard
A new Flutter package project.
Nations 🌍 #
Features #
- ✅ translation without context 🚀
- ✅ custom configuration
- ✅ value not found builder
- ✅ fallback locale
- ✅ supported locales
- ✅ fall back to base before loading the fallback
- ✅ Translation files Loaders
- ✅ json
- ✅ dart
- ✅ even Api or any data source 😎
- ✅ Translation
- ✅ Pluralization 💪
- ✅ single count
- ✅ range
- ✅ to infinity
- ✅ more the one number
- ✅ Attributes
- ✅ Nested translation 'validation.too_short' 🕸
- ✅ Gender
- ✅ Male
- ✅ Female
- ✅ Gender default
set the gender once then it will be used every were else
- ✅ Pluralization 💪
- ✅ App
- ✅ auto RTL - LTR based on the current locale
- ✅ reloading the app automatically 🔄
- ✅ automatically save the last preferred language in the shared preferences 🚀
- ✅ public API
- ✅ easily integrated with other packages to save more time and provided locaization out of the box base on your app configuration 🔥
- ✅ customization
- ✅ easy to override the messages 🔱
- ✅ capitalize first character in the first word
- ✅ capitalize first character in each word
- ✅ other
- ✅ support All Platforms ✔
- ✅ support Null-Safety ✔
Nations Assets #
this package contains translated message to use out of the box , no need to add them any more example
final message = 'login'.tr
print(message);
also you did't add login message in your assets and translate it to the your supported languages
it will use the nation assets and gets you the correct translated message
if the MaterialApp locale is arabic it will be تسجيل الدخول and if the locale is English it will be Sign In any so on out of the box
does this means i can't override the login keyword ? #
no the package will use the default values only if you don't have one in you assets so you can override it any time
does this package have a big data sets ? - Will This Make The App very big ? #
no this package will contains the necessary and the common keywords sings use in Authentication , Validation , searching , Filtering , introductions , ...etc and will be added manually to choses carefully which means you gonna support more languages out of the box in the entire app
Usage #
simple translation #
you can use the .tr extension or tr() function directly
'key'.tr
// or
tr('key')
Gender #
Male #
// male
'key'.trMale
// or
trMale('key')
Female #
// male
'key'.trFemale
// or
trFemale('key')
use the default gender #
/// * translate a text **AND** use the default gender
'key'.gender
gender('key')
translation attributes #
'key'.args(args)
trWithArgs('key',args)
plural #
'key'.plural(count,args)
trPlural('key',count,args)
Package Integration Example with queen_validators #

why make it like this ? #
- this will make packages takes control of the localization which will spare the developer of this responsibility
- like when using a validation package for example the failure message should be automatically localized out of the box !
- would this package prevent the developer to use custom translated messages ? No ,, it will only provide a default values in many languages out of the box !
- would this increase the app size ? No , this will provide the necessary values only
attributes #
which allows to customize the translated message
Example in validation : Arabic => "الحد الاقصي للحروف 255" English => "max length is 255"
255 is the max length and might changes some times is 255 or 55 or just 2 depend on the form how to achieve that in nations ?
"max_length_is":"max length is :count"
and in your code
final msg = 'max_length_is'.args({"count":255});
for now the generations is not done yet after we finish them no more String keys and dynamic parameters every thing will be hard type and stricter to avoid future bugs
Helpers #
- ✅
capitalizeFirstChar(String)to make the first word capital - ✅
capitalizeEachWordto make every word capital in one line more entire paragraph - ❌
numberToLocale(String,[Locale?])localize numbers based on locale
Whats next ? #
- ❌ make sure tests cover every thing
- ❌ Arabic Docs
- ❌ logs base on the flavor
- ❌ productivity - avoiding bugs
- ❌ VsCode extension
- ❌ Go to source
- ❌ See the Translated keyword
- ❌ add keyword to translations
- ❌ CLI - Lighthouse 💡
- ✅
lh make:localegenerate api for translation files - ❌
lh locale:fixshow bugs in the localization (same schema , duplicates , missing , same as the nation assets) 🔍🆕 - ❌
lh locale:listshow supported locales list - ❌
lh tr:shrinkshrinking assets by removing useless spaces before building - ❌ code generation
Tr.keyand you will get the translated message directly 🆕- ✅ show gender API
- ❌ show attributes API
- ❌ show plural API
- ✅ show nested API
- ✅
- ❌ VsCode extension