modified_localization 1.0.0 modified_localization: ^1.0.0 copied to clipboard
Flutter localization package
example #
Run in terminal : flutter pub run modified_localization:generate -o locale_keys.g.dart --source-dir /your_dir
example/resources/langs/en-EN.json #
{
"hi": "Hi !",
"welcome": "Welcome {}"
}
Will be generated strings class like this, then you can use it without .tr(), if arguments needed will be generated args function
import 'package:easy_localization/easy_localization.dart';
// DO NOT EDIT. This is code generated via package:easy_localization/generate.dart
abstract class Strings {
static final hi = 'hi'.tr();
static String welcome(String arg0) {
return 'welcome'.tr(args: [arg0]);
}
}
example/lib/main.dart #
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(Strings.hi),
Text(Strings.welcome("Flutter")),
],
),
alignment: Alignment.center,
),
);
}
}