custom-plugin-flutter-skill-localization
Production-grade Flutter localization mastery - ARB files, flutter_localizations, intl package, pluralization, RTL support, dynamic locale switching with comprehensive code examples
What this skill does
# custom-plugin-flutter: Localization Skill
## Quick Start - Production Localization Setup
```yaml
# pubspec.yaml
dependencies:
flutter_localizations:
sdk: flutter
intl: ^0.19.0
flutter:
generate: true
# l10n.yaml (create in project root)
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-class: AppLocalizations
nullable-getter: false
```
```dart
// lib/l10n/app_en.arb
{
"@@locale": "en",
"appTitle": "My App",
"@appTitle": {
"description": "The app title"
},
"welcomeMessage": "Welcome, {name}!",
"@welcomeMessage": {
"description": "Welcome message with user name",
"placeholders": {
"name": {
"type": "String",
"example": "John"
}
}
},
"itemCount": "{count, plural, =0{No items} =1{1 item} other{{count} items}}",
"@itemCount": {
"description": "Number of items",
"placeholders": {
"count": {
"type": "int"
}
}
}
}
// lib/l10n/app_tr.arb
{
"@@locale": "tr",
"appTitle": "Uygulamam",
"welcomeMessage": "Hoş geldin, {name}!",
"itemCount": "{count, plural, =0{Öğe yok} =1{1 öğe} other{{count} öğe}}"
}
// main.dart
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: Locale('en'),
home: HomePage(),
);
}
}
// Usage in widgets
Text(AppLocalizations.of(context).welcomeMessage('John'))
Text(AppLocalizations.of(context).itemCount(5))
```
## 1. ARB File Syntax
### Basic Messages
```json
{
"@@locale": "en",
"greeting": "Hello",
"@greeting": {
"description": "A simple greeting"
},
"pageTitle": "Settings Page",
"@pageTitle": {
"description": "Title of the settings page",
"context": "SettingsPage"
}
}
```
### Placeholders
```json
{
"welcomeUser": "Welcome, {userName}!",
"@welcomeUser": {
"placeholders": {
"userName": {
"type": "String",
"example": "Alice"
}
}
},
"priceLabel": "Price: {price}",
"@priceLabel": {
"placeholders": {
"price": {
"type": "double",
"format": "currency",
"optionalParameters": {
"symbol": "$",
"decimalDigits": 2
}
}
}
},
"dateLabel": "Date: {date}",
"@dateLabel": {
"placeholders": {
"date": {
"type": "DateTime",
"format": "yMMMd"
}
}
}
}
```
### Pluralization
```json
{
"cartItems": "{count, plural, =0{Your cart is empty} =1{1 item in cart} other{{count} items in cart}}",
"@cartItems": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"remainingAttempts": "{count, plural, =0{No attempts remaining} =1{1 attempt remaining} other{{count} attempts remaining}}",
"@remainingAttempts": {
"placeholders": {
"count": {
"type": "int"
}
}
}
}
```
### Gender Selection
```json
{
"userGreeting": "{gender, select, male{Mr. {name}} female{Ms. {name}} other{{name}}}",
"@userGreeting": {
"placeholders": {
"gender": {
"type": "String"
},
"name": {
"type": "String"
}
}
}
}
```
## 2. Date & Number Formatting
```dart
import 'package:intl/intl.dart';
// Date formatting
final dateFormatter = DateFormat.yMMMd(locale);
Text(dateFormatter.format(DateTime.now()))
// Number formatting
final numberFormatter = NumberFormat.decimalPattern(locale);
Text(numberFormatter.format(1234567.89))
// Currency formatting
final currencyFormatter = NumberFormat.currency(
locale: locale,
symbol: '\$',
decimalDigits: 2,
);
Text(currencyFormatter.format(99.99))
// Percentage
final percentFormatter = NumberFormat.percentPattern(locale);
Text(percentFormatter.format(0.75)) // 75%
// Compact notation
final compactFormatter = NumberFormat.compact(locale: locale);
Text(compactFormatter.format(1500000)) // 1.5M
```
## 3. Dynamic Locale Switching
```dart
class LocaleProvider extends ChangeNotifier {
Locale _locale = Locale('en');
Locale get locale => _locale;
void setLocale(Locale locale) {
if (!AppLocalizations.supportedLocales.contains(locale)) return;
_locale = locale;
notifyListeners();
}
Future<void> loadSavedLocale() async {
final prefs = await SharedPreferences.getInstance();
final languageCode = prefs.getString('languageCode');
if (languageCode != null) {
_locale = Locale(languageCode);
notifyListeners();
}
}
Future<void> saveLocale(Locale locale) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setString('languageCode', locale.languageCode);
setLocale(locale);
}
}
// Usage with Provider
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<LocaleProvider>(
builder: (context, localeProvider, child) {
return MaterialApp(
locale: localeProvider.locale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: HomePage(),
);
},
);
}
}
// Language selector
class LanguageSelector extends StatelessWidget {
@override
Widget build(BuildContext context) {
final localeProvider = context.watch<LocaleProvider>();
return DropdownButton<Locale>(
value: localeProvider.locale,
items: AppLocalizations.supportedLocales.map((locale) {
return DropdownMenuItem(
value: locale,
child: Text(_getLanguageName(locale)),
);
}).toList(),
onChanged: (locale) {
if (locale != null) {
localeProvider.saveLocale(locale);
}
},
);
}
String _getLanguageName(Locale locale) {
switch (locale.languageCode) {
case 'en': return 'English';
case 'tr': return 'Türkçe';
case 'es': return 'Español';
default: return locale.languageCode;
}
}
}
```
## 4. RTL (Right-to-Left) Support
```dart
// Automatic direction based on locale
MaterialApp(
locale: Locale('ar'), // Arabic - RTL
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
)
// Check directionality
final isRtl = Directionality.of(context) == TextDirection.rtl;
// Force direction
Directionality(
textDirection: TextDirection.rtl,
child: MyWidget(),
)
// Directional padding
Padding(
padding: EdgeInsetsDirectional.only(start: 16, end: 8),
child: Text('Directional padding'),
)
// Positioned directionally
PositionedDirectional(
start: 0,
end: null,
child: widget,
)
// Row with automatic alignment
Row(
textDirection: Directionality.of(context),
children: [...],
)
// Icons that should flip
Transform.flip(
flipX: isRtl,
child: Icon(Icons.arrow_forward),
)
```
## 5. Testing Localization
```dart
void main() {
testWidgets('displays localized text in Turkish', (tester) async {
await tester.pumpWidget(
MaterialApp(
locale: Locale('tr'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: HomePage(),
),
);
expect(find.text('Hoş geldin!'), findsOneWidget);
});
testWidgets('handles pluralization correctly', (tester) async {
await tester.pumpWidget(
MaterialApp(
locale: Locale('en'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Builder(
builder: (context) {
return Column(
children: [
Text(AppLocalizations.of(context).itemCount(0)),
Text(ApRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.