Closed d-apps closed 4 years ago
if get made internalization too that would be too much kkkkk
this orientation thing i think he added today, or maybe it was there from the beginning and i haven't noticed, but it's there
if get made internalization too that would be too much kkkkk
this orientation thing i think he added today, or maybe it was there from the beginning and i haven't noticed, but it's there
Nice if he added Orientation today, but I want to know about the others...possibility :)
It is very easy to do localization, as long as it does not involve using assets. In 2 min typing this comment, I wrote a solution to use the text itself as a key, and it would work just by adding ".tr" at the end of each String. But I'm afraid to implement this, and ask to implement the reading of the assets and this will become a snowball. It seems that each feature added means more issues about this new feature hahaha.
extension Translation on String{
String get tr => trans(this);
}
trans(String toTransl){
String locale = Get().locale.toString();
Get().translations[toTransl][locale];
}
init(){
Get.registerTraslations({
"oi": {"EN": "Hi", "ES": "Holla"}
});
}
class Get {
Locale locale;
Map<String, Map<String, String>> translations = {};
Get.registerTraslations(Map<String, Map<String, String>> tr){
translations = tr;
}
}
Text("oi".tr); // usage
It is very easy to do localization, as long as it does not involve using assets. In 2 min typing this comment, I wrote a solution to use the text itself as a key, and it would work just by adding ".tr" at the end of each String. But I'm afraid to implement this, and ask to implement the reading of the assets and this will become a snowball. It seems that each feature added means more issues about this new feature hahaha.
extension Translation on String{ String get tr => trans(this); } trans(String toTransl){ String locale = Get().locale.toString(); Get().translations[toTransl][locale]; } init(){ Get.registerTraslations({ "oi": {"EN": "Hi", "ES": "Holla"} }); } class Get { Locale locale; Map<String, Map<String, String>> translations = {}; Get.registerTraslations(Map<String, Map<String, String>> tr){ translations = tr; } }
Text("oi".tr); // usage
What about the others?
i absolutely love the ideia of using the own string as a key, just the way is used in gettext for example. But i understand that making this really good would add a lot of work. There is a package that i think is very good, although i did not used it, the documentation show that are good things, and i think who made is brazilian too 😄 https://pub.dev/packages/i18n_extension
i absolutely love the ideia of using the own string as a key, just the way is used in gettext for example. But i understand that making this really good would add a lot of work. There is a package that i think is very good, although i did not used it, the documentation show that are good things, and i think who made is brazilian too https://pub.dev/packages/i18n_extension
Brazilians think alike, I've used a version of this since dart 2.6 (which launched the extensions) and I didn't know there was a package for that hahaha
Hey Jonny I made a package for me that has some methods that I always use on my projects, could you please take a look and see if is possible to add them on Get? I think some are really useful features that Get doesn't have yet and could help a lot of developers, all methods are available on my package; https://github.com/d-apps/djalma_util/tree/master/lib/src
- A method that converts Color to MaterialColor, it's useful when you want to use like: Color.blue[600] inside ThemeData's primarySwatch since it just allow use Colors.blue, the color directly without shade.
- FirebaseErrorChecker, to check errors coming from firebase, that would be good. (I know that is a little out of Get's scope but I tried kkkk) the error I have on my package.
- Get.orientation, a method that retrieves the phone's current orientation.
- DateFormatter, where we can specify like only "pt-BR" and it formats automatically to Brazil date format, it uses intl package.
This could be really useful.
The idea of Firebase is good, but very restricted to one language. If it were something like: Displaying a snackbar, and being able to set the message according to the language would be great! Creating an enum for each error can also be nice. Maybe if the internationalization package is launched, it could be cool. I'm thinking of launching micropackages for Get, a way to get the community engaged, and at the same time, everyone's work will be publicized. I'm going to put these micropackages in the Get description, maybe instead of putting them in the main, people can use these packages together. Since Get has many readme views per week, this can give evidence to other developers as well.
abstract class GetWidget
abstract class GetWidget<T> extends StatelessWidget {
T get controller => Get.find();
const GetWidget({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context);
}
example
class HomePage extends GetWidget<HomePageController> {
const HomePage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(child: Obx(() => Text(controller.text));
}
}
One favor I would like to ask for:
At the moment "Get.bottomSheet()" returns a Modal Bottom Sheet, but I was wondering if you could also add the Persistent Bottom Sheet ?
Modal: https://api.flutter.dev/flutter/material/showModalBottomSheet.html Persistent: https://api.flutter.dev/flutter/material/showBottomSheet.html
Modal Bottom Sheet makes the rest of the screen inactive but I would need the behavior of the Persistent Bottom Sheet where the user can interact with the rest of the screen when the bottom sheet is shown.
@jonataslaw some of those feature request were already made, do you plan on making the rest? what's missing is the firebase error checker and the DateFormatter
Internationalization has been implemented, the firebase error check I think it might not be good to be part of the main package, because it is very specific, maybe we will make a specific package for firebase in the future to facilitate not only this, but other resources. The color palette, if the author wants to implement it, can feel free to make a PR, and finally tools that depend on internationalization, such as DateFormat would make this library very large, because translation packages are usually very large. I added intl to a web project, and it doubled the file size. Well, thanks for all the suggestions, but I think that can be closed. If you find something useful that you can do, do not hesitate to open a PR, any contribution is welcome.
Hey Jonny I made a package for me that has some methods that I always use on my projects, could you please take a look and see if is possible to add them on Get? I think some are really useful features that Get doesn't have yet and could help a lot of developers, all methods are available on my package; https://github.com/d-apps/djalma_util/tree/master/lib/src
A method that converts Color to MaterialColor, it's useful when you want to use like: Color.blue[600] inside ThemeData's primarySwatch since it just allow use Colors.blue, the color directly without shade.
FirebaseErrorChecker, to check errors coming from firebase, that would be good. (I know that is a little out of Get's scope but I tried kkkk) the error I have on my package.
Get.orientation, a method that retrieves the phone's current orientation.
DateFormatter, where we can specify like only "pt-BR" and it formats automatically to Brazil date format, it uses intl package.
This could be really useful.