Тёмный

Flutter Localization the Easy Way - using JSON 

Coding Orbit
Подписаться 4 тыс.
Просмотров 4,8 тыс.
50% 1

Hey Guys, in this Flutter video I will show you how to implement localization in your flutter app. You will learn how to localize your flutter app the easy way, using JSON and delegates. You will also learn how to switch the language of the app inside the app.
The localization will work based on the device language or it will use the default language if the device language isn't localized in the app. Also, it will have a button to toggle the language inside the app.
At the end of the video, you will have multiple language support for your flutter app.
For more Flutter content be sure to subscribe to the channel and turn on your notifications.
Check out Flutter how-to videos:
• Flutter Google Ads
Check out my Flutter tutorial to become a Flutter hero: • Flutter Tutorial for B...
Links:
Don't click this: bit.ly/3dkJUNB
Pub dev library: pub.dev/packages/get/install
Github source code: github.com/Coding-Orbit/flutt...
Update pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
-------- Content of this video --------
00:00 Demo of the finished app
00:58 Setting up our project
01:15 Adding JSON files
02:15 Implementing Localization class
08:29 Adding delegates
12:28 Adding Localization to material app
13:09 Using the localization
13:50 Automating the use of localization
16:41 Testing the localization
18:00 Implementing in-app toggle language
24:00 Testing the app
#flutter #flutter_localization #flutter_localization_json #flutter_localization_tutorial

Опубликовано:

 

5 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 27   
@ashishdhiman2007
@ashishdhiman2007 Год назад
It was helpful, thanks
@codingorbit
@codingorbit Год назад
Glad to hear that!
@bewhy6410
@bewhy6410 2 года назад
I swear you are the best the best the best please keep going
@codingorbit
@codingorbit 2 года назад
Thank you! I really appreciate that!
@riskzerobeatz
@riskzerobeatz 2 года назад
Nice!
@codingorbit
@codingorbit 2 года назад
Thanks!
@yagizdo
@yagizdo 2 года назад
How can we save it to localstorage and use it? I saved it in sharedprefs with a method every time the language was changed. Then I took it in main and put it in Locale. But it didn't work, it took the language of the phone again.
@codingorbit
@codingorbit 2 года назад
I think the best option is to save the languageCode in shared preferences in LocalizationService in the load method instead of this final jsonString = await rootBundle.loadString('lang/${locale.languageCode}.json'); type this final jsonString = await rootBundle.loadString('lang/${savedLocal}.json'); and savedLocal is the saved language code.
@yosbel12
@yosbel12 Год назад
Having error ---- return Localizations.of(context, LocalizationService); on this code _TypeError (type 'Null' is not a subtype of type 'LocalizationService')
@codingorbit
@codingorbit Год назад
I guess you have to check on the it if its not null you can force unwrap it
@mohamedleminelbechir6604
@mohamedleminelbechir6604 2 года назад
Thanks you , how can I make a default langauge if the phone langauge is not supported (for example if the phone langauge is ES or china.. I went it to be AR)
@codingorbit
@codingorbit 2 года назад
You can change few things in the localisation service to make it by default return the ar file
@mohamedleminelbechir6604
@mohamedleminelbechir6604 2 года назад
@@codingorbit Thank you , I tried a lot of changes but nothing work with me
@codingorbit
@codingorbit 2 года назад
@@mohamedleminelbechir6604 Have you tried changing some code in the method "localeResolutionCallBack"? since you can return ar instead of supportedLocales.first in the else statement.
@codingorbit
@codingorbit 2 года назад
Or you can do something different Save the languageCode in shared preferences in LocalizationService in the load method instead of this final jsonString = await rootBundle.loadString('lang/${locale.languageCode}.json'); type this final jsonString = await rootBundle.loadString('lang/${savedLocal}.json'); and savedLocal is the saved language code. And when the user change the language change it also in shared preferences
@mohamedleminelbechir6604
@mohamedleminelbechir6604 2 года назад
Ok thank you again 🙏
@hasnatshahzad4573
@hasnatshahzad4573 2 года назад
Please make a video on flutter package dio post form data to api. Thank you
@codingorbit
@codingorbit 2 года назад
Thank you, maybe soon
@qussaiqassim9912
@qussaiqassim9912 2 года назад
👍🏾
@metacode4696
@metacode4696 2 года назад
sir,,, how to Implementing in-app toggle language using Provider state management?
@codingorbit
@codingorbit 2 года назад
Same concept as getx but use what provider uses like wrapping it with consumer
@abdelouahebbenouar6157
@abdelouahebbenouar6157 Год назад
I'm facing a problem.. if the system language is english.. everytime i open the app it always choose the system language.. even tho before exiting i chosed arabic for example
@codingorbit
@codingorbit Год назад
I think the best option is to save the languageCode in shared preferences in LocalizationService in the load method instead of this final jsonString = await rootBundle.loadString('lang/${locale.languageCode}.json'); type this final jsonString = await rootBundle.loadString('lang/${savedLocal}.json'); and savedLocal is the saved language code.
@abdelouahebbenouar6157
@abdelouahebbenouar6157 Год назад
@@codingorbit can you help me implement it using your code please ? I'm kinda new but i need to implement it on my app
@abdelouahebbenouar6157
@abdelouahebbenouar6157 Год назад
Please?
@Kolompos1
@Kolompos1 Год назад
Explaining how to write a code requires explaining. What you are doing is writing a somewhat prewritten code and stating the words you type in... Just post it to github -.-
@codingorbit
@codingorbit Год назад
Thank you for your feedback, it was one of the first videos i ever made lol, and thats not an excuse but i hope you might find other videos newly created helpful
Далее
Flutter Native Splash Screen Android & iOS
5:51
Просмотров 2,8 тыс.
Впервые дал другу машину…
00:57
Flutter Localization - Official Documentation
35:01
Просмотров 36 тыс.
Flutter Consume Rest API With Best Practices
31:27
Просмотров 25 тыс.
Flutter Animated Expandable Floating Action Button
21:13
How to use Easy Localization package? | Flutter
20:42
Flutter Multiple Language App | Localization Support
44:33