flutter_ui_kit_l10n 0.0.46 copy "flutter_ui_kit_l10n: ^0.0.46" to clipboard
flutter_ui_kit_l10n: ^0.0.46 copied to clipboard

Shared localization package for Flutter UI Kit monorepo. Provides common UI translations reusable across multiple Flutter apps.

Flutter UI KIT L10n #

Shared localization package for Flutter UI Kit monorepo.

Provides UiKitLocalizations — a set of common UI translations (en, ko, ja) reusable across multiple Flutter apps.

Quick start #

import 'package:flutter_ui_kit_l10n/flutter_ui_kit_l10n.dart';

MaterialApp(
  localizationsDelegates: [
    UiKitLocalizations.delegate,
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: UiKitLocalizations.supportedLocales,
)

// In widgets:
final l10n = UiKitLocalizations.of(context);
Text(l10n.settings);

Namespace-scoped access #

ARB 키는 도메인별 네임스페이스(auth, common, core, notice, settings, terminal, time, validation)로 나뉘어 있다. 같은 도메인 키만 모아서 쓰고 싶다면 UiKitLocalizations.of(context).ns.<namespace> 진입점을 사용한다.

final l10n = UiKitLocalizations.of(context);

// flat access (기존)
Text(l10n.appTitle);
Text(l10n.deleteConfirm('MyHost'));

// namespace access (권장 — 도메인이 명확)
Text(l10n.ns.terminal.appTitle);
Text(l10n.ns.terminal.deleteConfirm('MyHost'));
Text(l10n.ns.auth.login);
Text(l10n.ns.validation.passwordTooShort(8));

각 네임스페이스 클래스(TerminalL10n, AuthL10n, CommonL10n, CoreL10n, NoticeL10n, SettingsL10n, TimeL10n, ValidationL10n)는 해당 ARB 네임스페이스(l10n/namespaces/{ns}_*.arb)에 정의된 키만 노출한다.

Current locale #

// Get current locale from context
final locale = Localizations.localeOf(context);
print(locale.languageCode); // "en", "ko", "ja"

// Get localised strings for the current locale
final l10n = UiKitLocalizations.of(context);
Text(l10n.settingsLanguage); // "Language" / "언어" / "言語"

Change locale at runtime #

Use a ValueNotifier<Locale> to manage the locale state and wrap MaterialApp with ValueListenableBuilder:

class MyApp extends StatelessWidget {
  MyApp({super.key});

  final _localeNotifier = ValueNotifier(const Locale('en'));

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<Locale>(
      valueListenable: _localeNotifier,
      builder: (_, locale, __) => MaterialApp(
        locale: locale,
        localizationsDelegates: [
          UiKitLocalizations.delegate,
          GlobalMaterialLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: UiKitLocalizations.supportedLocales,
        home: HomeScreen(localeNotifier: _localeNotifier),
      ),
    );
  }
}

UiKitLocaleToggle #

A ready-made toggle button that cycles through supported locales on each tap. It displays the current locale code (e.g. ENKOJAEN).

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key, required this.localeNotifier});

  final ValueNotifier<Locale> localeNotifier;

  @override
  Widget build(BuildContext context) {
    final l10n = UiKitLocalizations.of(context);
    final currentLocale = Localizations.localeOf(context);

    return Scaffold(
      appBar: AppBar(
        title: Text(l10n.settings),
        actions: [
          // Tap to cycle: EN → KO → JA → EN ...
          UiKitLocaleToggle(
            currentLocale: currentLocale,
            onLocaleChanged: (locale) => localeNotifier.value = locale,
          ),
        ],
      ),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text('${l10n.settingsLanguage}: ${currentLocale.languageCode}'),
            Text(l10n.settingsTheme),
            Text(l10n.settingsAccount),
          ],
        ),
      ),
    );
  }
}

App-level override #

Use UiKitLocalizationsOverrideDelegate instead of UiKitLocalizations.delegate when you need to customise individual strings per app:

// 1. Extend and override specific getters
class MyAppLocalizationsEn extends UiKitLocalizationsEn {
  @override
  String get settings => 'App Settings';

  @override
  String get addItem => 'Add D-Day';
}

// 2. Pass the override delegate
MaterialApp(
  localizationsDelegates: [
    UiKitLocalizationsOverrideDelegate(
      overrideFactory: (locale) => switch (locale.languageCode) {
        'en' => MyAppLocalizationsEn(),
        'ko' => MyAppLocalizationsKo(),
        _ => null, // falls back to shared default
      },
    ),
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: UiKitLocalizations.supportedLocales,
)

Supported locales #

Code Language
en English
ko Korean
ja Japanese

Custom #

  final l10n = UiKitLocalizations.of(context);

  Text(
    l10n.custom((locale) => switch (locale.languageCode) {
      'en' => 'This alarm is important',
      'ko' => '이 알람은 중요합니다',
      _ => 'Unknown',
    }),
  )
0
likes
150
points
176
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Shared localization package for Flutter UI Kit monorepo. Provides common UI translations reusable across multiple Flutter apps.

Repository (GitHub)
View/report issues

Topics

#l10n #localization #i18n #ui #design-system

License

MIT (license)

Dependencies

flutter, flutter_localizations, flutter_ui_kit_widget, intl

More

Packages that depend on flutter_ui_kit_l10n