Please note i am not talking about the .abr files.
I have been following several tutorials on internationalization in Flutter using the intl package. I noticed that they always use a single AppLocalization class for storing all the messages that will be used in the application. Since it was a tutorial, I am wondering if we will always have to do it that way. I mean in a real application we will probably have hundreds messages to maintain. It would be a mess to put them all in a single class.
Maybe we should have a localization class for each Page?
What are your suggestions?
Flutter Intl package it's the right solution; also i used to Easy Localization.
This package has a "inherited widget " concept, so if you want to change automatically change UI for changed Local Language, it will be quite useful to you.
Maybe you want to localization JSON update to server and use application new key-value without deploy store. EasyLocalzation does read the server-side JSON file.
Related
I have many pages and I want to share file content between some pages, also giving this pages ability to modify content, the file contains (obj, data (int, bool, ...)).
1st: share file content between some pages can be done by using Constructor.
2nd: ability to modify conten can only be done by global variable+ key, but go for stateManagement.
I suggest, you should go for StateManagement. It can handle that.
I perefer using riverpod, also people suggest using getx being easy to use.
for more read this.
You can try the provider package as it's an effective tool for sharing data a cross your flutter app: https://flutter.dev/docs/development/data-and-backend/state-mgmt/simple
Either use constructors to dig through the widgets or simply use one of the packages for state management like provider, getx, bloc and many others.
But if you are a beginner then go with provider package as it is recommended by flutter team
I'm in a situation where I could really use functionality to change meta-data in manifest at run-time in my Flutter app. As per my understanding, the androidmanifest.xml elements are only set at compile-time. While trying to find some solution, I came across this and this which says otherwise.
Now I'm curious to know if it is really possible to update these meta-data(s) at runtime? If yes then how to implement this functionality on Flutter?
Yes, updating meta-data is possible in Android, but it's limited to some tags.
About modifying them via Flutter, just like any other platform-specific API, you should use channels:
https://flutter.dev/docs/development/platform-integration/platform-channels
It looks complex but easy to use. Check the battery level reading sample above, it's quite clear.
I have one project that I have to sell to another clients, so I wanna found a way to unify the code to, when I release some updates, I have to manipulate only one code (and, of course, keeping the specificities from each one)
I found an article HERE which the guy creates a new folder named 'config' and set some variables there to be used in the parent project. I tried this but find out that would be very tough to do because the first app was developed specifically by one client, and with it I would need so much time to make all the aspects dynamic... Another problem is firebase, in first app I used firebase but in the second i won't. How to make it possible?
And in this article they say about 'flavours' that can be used to do something similar.
Someone knows about this approaches or there is another to reach my goal? With flavours I will have less re-factor than with config?
I appreciate any help
A third way to do this with no client specific app configuration is to make an api call to get back your client specific theme, and then set the flutter theme based on this.
If you need web support see below:
First update your assets in index.html that aren't white labeled, leaving stubs in their place that we'll fill in later. i.e.
Next show a nice loading indicator while flutter loads. To do this, just put the html for it in the body element of the index.html file.
Finally update the webpage title and favicon using javascript inside Flutter. I used package
universal_html: 2.0.8
https://pub.dev/packages/universal_html
then you can update the favicon
import 'package:universal_html/html.dart';
var favicon = document.getElementById('favicon');
favicon?.setAttribute('href','insertLinkToYourImage');
Updating the title can be accomplished in various normal ways like just setting the title attribute of a MaterialApp widget.
I'm going to make 10-50 different apps with the same codebase. So I'll probably have to use flavors. But is there a simpler way?
The only thing that's going to be different in the apps is the title, logo, maybe background, MP3 files and some text in the apps. Everything else will be the same.
What's the most straightforward way to do this? Can someone send some ressources I can learn from?
In my experience, I wrote multiple main.dart files. instead of having one lib/main.dart, we can have more e.g lib/main-us.dart, lib/main-uk.dart, lib/main-ge.dart.
in those files, we can put some parameters within MyApp using either Dependency Injection or Inherited Widget, therefore all children widgets can display correspondingly to its flavor
YES!
you can have :
Multiple configs so you can have some of this in flutter code base. [ apiBaseUrl , OnseSignalId , etc..
Flavors in both platform so you can have multiple apps ( applciation id in android and bundle id in ios ) and multiple folder for resources like Google-Service.json...
I have a set of GWT UIs, some created directly in Java and others created using UI Binder ui.xml files.
I localized them following the official GWT guidelines (e.g. creating interface extending Messages interface).
I now wonder if there is an easy way to write a unit test to validate that message keys get replaced by the corresponding values from property files?
I guess I could do that using GWTTestCase, but actually I don't need a browser to render the page. Instead, it would be enough to get the raw string output and check with some regex that the messages are present.
Is that possible? Or is it better to test such things in running application like using Selenium?
Just a note. Besides the important things you are trying to validate, one of the critical points in my project during messages localization tests is to see: if the translated text fits the allocated space. If it's a box of fixed size, overlapping texts don't look nice. And this cannot be checked with unit tests. That's why the manual review is in to-do list when new locale is added or certain labels/messages are changed.
I'd recommend Selenium. Checking that the messages are present could be tricky, because in that case you should know the place where the label is located, in which tags. In my opinion, using GWTTestCase makes sense when it comes to testing controllers' behavior. Simple search by value guarantees only presence but not correct placement.
I think, it also makes sense to use those translation properties in the tests, so the strings are not duplicates in the tests.