-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Localization generator request #6
Comments
can be a simple key / value map static const Map<String, dynamic> en_US = {
"menu.logoutBtn": "Log out",
"menu.items.settings": "Settings",
}; |
Agree 💯 , super useful feature for code generation. |
I have implemented this, now I will post a pull request |
What a fantastic idea, I really liked it |
PR #7 assets/locales - input directory with json files get generate locales assets/locales output file // DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart
abstract class LocaleKeys {
static const simple = 'simple';
static const menu_logoutBtn = 'menu_logoutBtn';
static const menu_items_settings = 'menu_items_settings';
static const menu_items_notifications = 'menu_items_notifications';
static const menu_items_wallet = 'menu_items_wallet';
}
abstract class Locales {
static const en_US = {
'simple': 'The Simple',
'menu_logoutBtn': 'Log out',
'menu_items_settings': 'Settings',
'menu_items_notifications': 'Notifications',
'menu_items_wallet': 'Wallet',
};
static const ru_RU = {
'menu_logoutBtn': 'Выход',
'menu_items_settings': 'Настройки',
'menu_items_notifications': 'Оповещения',
'menu_items_wallet': 'Кошелёк',
};
} |
congratulations!! you did an excellent job |
I will close this issue |
Sorry for the dump question, but i could not figure out how to use the generated locales. main.dart void main() {
runApp(
GetMaterialApp(
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
translationsKeys: AppTranslation.translations,
locale: Locale('en', 'US'),
fallbackLocale: Locale('en', 'US'),
supportedLocales: <Locale>[Locale('en', 'US'), Locale('zh', 'CN')],
debugShowCheckedModeBanner: false,
),
);
} i have tried: Text(LocaleKeys.titles_home.tr) // not working
Text(LocaleKeys.titles_home) // not working
Text('titles_home'.tr) // not working Thank you for the help in advance. |
is the text output in English or it's empty? |
The out put is titles_home instead of it's content. |
@CpdnCristiano or any one please help? The generated locales.g.dart: // DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart
abstract class AppTranslation {
static Map<String, Map<String, String>> translations = {
'zh_CN': Locales.zh_CN,
'en_EN': Locales.en_EN,
};
}
abstract class LocaleKeys {
static const titles_home = 'titles_home';
static const buttons_sign_up = 'buttons_sign_up';
static const buttons_sign_in = 'buttons_sign_in';
static const buttons_logout = 'buttons_logout';
}
abstract class Locales {
static const zh_CN = {
'titles_home': '首页',
'buttons_sign_up': '注册',
'buttons_sign_in': '登入',
'buttons_logout': '退出',
};
static const en_EN = {
'titles_home': 'Home',
'buttons_sign_up': 'Sign Up',
'buttons_sign_in': 'Sign in',
'buttons_logout': 'Logout',
};
} In the app it shows the |
you generated for the locale |
Thank you for the shape eye, didn't notice the example was using |
It would be great to add a localization generator from json files to get_cli, while generating an abstract class with keys and translation maps, just like in the easy_localization package.
input directory
generated keys
generated localization maps
using
The text was updated successfully, but these errors were encountered: