Loading...
Loading...
Compare original and translation side by side
pubspec.yamldependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
flutter:
generate: true # Required for l10n code generationl10n.yamlgen-l10narb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dartpubspec.yamldependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
flutter:
generate: true # Required for l10n code generationl10n.yamlgen-l10narb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dartundefinedundefined.arbarb-dirlib/l10n/app_en.arb{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
}
}lib/l10n/app_es.arb{
"helloWorld": "¡Hola Mundo!"
}arb-dir.arblib/l10n/app_en.arb{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
}
}lib/l10n/app_es.arb{
"helloWorld": "¡Hola Mundo!"
}LocalizationsMaterialAppCupertinoAppimport 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; // Adjust import if synthetic-package is false
return MaterialApp(
title: 'Localized App',
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en'), // English
Locale('es'), // Spanish
],
home: const MyHomePage(),
);AppLocalizationsText(AppLocalizations.of(context)!.helloWorld)WidgetsAppMaterialAppGlobalMaterialLocalizations.delegateMaterialAppCupertinoAppLocalizationsimport 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; // 若synthetic-package设为false,请调整导入路径
return MaterialApp(
title: 'Localized App',
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en'), // English
Locale('es'), // Spanish
],
home: const MyHomePage(),
);AppLocalizationsText(AppLocalizations.of(context)!.helloWorld)WidgetsAppMaterialAppGlobalMaterialLocalizations.delegate@key@key"hello": "Hello {userName}",
"@hello": {
"description": "A message with a single parameter",
"placeholders": {
"userName": {
"type": "String",
"example": "Bob"
}
}
}"hello": "Hello {userName}",
"@hello": {
"description": "A message with a single parameter",
"placeholders": {
"userName": {
"type": "String",
"example": "Bob"
}
}
}"nWombats": "{count, plural, =0{no wombats} =1{1 wombat} other{{count} wombats}}",
"@nWombats": {
"placeholders": {
"count": {
"type": "num",
"format": "compact"
}
}
}"nWombats": "{count, plural, =0{no wombats} =1{1 wombat} other{{count} wombats}}",
"@nWombats": {
"placeholders": {
"count": {
"type": "num",
"format": "compact"
}
}
}"pronoun": "{gender, select, male{he} female{she} other{they}}",
"@pronoun": {
"placeholders": {
"gender": {
"type": "String"
}
}
}"pronoun": "{gender, select, male{he} female{she} other{they}}",
"@pronoun": {
"placeholders": {
"gender": {
"type": "String"
}
}
}formatoptionalParametersintl"dateMessage": "Date: {date}",
"@dateMessage": {
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMd"
}
}
}formatoptionalParametersintl"dateMessage": "Date: {date}",
"@dateMessage": {
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMd"
}
}
}.arbarb-dirapp_fr.arb.arbLocalesupportedLocalesMaterialAppflutter gen-l10nAppLocalizationsarb-dir.arbapp_fr.arb.arbMaterialAppsupportedLocalesLocaleflutter gen-l10nAppLocalizationsios/Runner.xcodeprojRunnerInfo+project.pbxprojios/Runner.xcodeprojRunner+project.pbxprojTextFieldCupertinoTabBarLocalizationsMaterialLocalizationsCupertinoLocalizationsNo MaterialLocalizations found.CupertinoTabBar requires a Localizations parent...MaterialAppCupertinoAppWidgetsAppLocalizationsLocalizations(
locale: const Locale('en', 'US'),
delegates: const [
DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, // Required for TextField
DefaultCupertinoLocalizations.delegate, // Required for CupertinoTabBar
],
child: child,
)TextFieldCupertinoTabBarMaterialLocalizationsCupertinoLocalizationsLocalizationsNo MaterialLocalizations found.CupertinoTabBar requires a Localizations parent...MaterialAppCupertinoAppWidgetsAppLocalizationsLocalizations(
locale: const Locale('en', 'US'),
delegates: const [
DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate, // Required for TextField
DefaultCupertinoLocalizations.delegate, // Required for CupertinoTabBar
],
child: child,
)Locale.fromSubtagsscriptCodecountryCodesupportedLocales: const [
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN'),
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'TW'),
]Locale.fromSubtagsscriptCodecountryCodesupportedLocales: const [
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN'),
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'TW'),
]