MaterialApp(
title: '',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.black),
scaffoldBackgroundColor: Color(globalBackgroundColor),
useMaterial3: true,
),
home: const MyHomePage(title: ''),
localizationsDelegates: [
FlutterI18nDelegate(
translationLoader: FileTranslationLoader(
decodeStrategies: [JsonDecodeStrategy()],
useCountryCode: true,
fallbackFile: 'en_US',
basePath: 'assets/i18n',
),
missingTranslationHandler: (key, locale) {
print("--- Missing Key: $key, languageCode: ${locale!.languageCode.toString()}");
},
),
],
);
change language
InkWell(
onTap:() async {
await FlutterI18n.refresh(context,Locale('en', 'US') );
print( FlutterI18n.currentLocale(context) );
print('5641:'+FlutterI18n.translate(context, "hw") );
},
child: Container(width: 20,height: 20,color: Colors.grey,)),
pubspec.yaml
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/
- assets/i18n/
沒有留言:
發佈留言