Loading...
Loading...
Configure your Flutter app to support different languages and regions
npx skill4agent add flutter/skills flutter-localizationflutter_localizationsintll10n.yamlMaterialAppCupertinoAppWidgetsApp.arbTextFieldCupertinoTabBarMaterialAppCupertinoAppWidgetsAppInfo.plistproject.pbxprojTextFieldCupertinoTabBarLocalizationszh_Hans_CNLocale.fromSubtagsLocalepubspec.yamldependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
flutter:
generate: truel10n.yamlarb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
synthetic-package: false.arblib/l10n/app_en.arb{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "Standard greeting"
},
"greeting": "Hello {userName}",
"@greeting": {
"description": "Greeting with a parameter",
"placeholders": {
"userName": {
"type": "String"
}
}
},
"nWombats": "{count, plural, =0{no wombats} =1{1 wombat} other{{count} wombats}}",
"@nWombats": {
"placeholders": {
"count": {
"type": "num",
"format": "compact"
}
}
}
}MaterialAppCupertinoAppimport 'package:flutter_localizations/flutter_localizations.dart';
import 'package:your_app_name/l10n/app_localizations.dart'; // Adjust path based on synthetic-package setting
// Inside your root widget build method:
return MaterialApp(
title: 'Localized App',
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('en', ''), // English
Locale('es', ''), // Spanish
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN'),
],
home: const MyHomePage(),
);TextFieldCupertinoTabBarMaterialLocalizationsLocalizationsLocalizationsLocalizations(
locale: const Locale('en', 'US'),
delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
],
child: CupertinoTabBar(
items: const <BottomNavigationBarItem>[...],
),
)ios/Runner.xcodeprojRunnerInfo+flutter gen-l10napp_localizations.dartlocalizationsDelegatessynthetic-package: falsegenerate: truepackage:flutter_gensynthetic-package: falseTextFieldMaterialLocalizationsCupertinoTabBarLocalizationsLocale.fromSubtagszh_Hanszh_Hant.arb@{}'.arbuse-escaping: truel10n.yaml''