FLUTTER ECOSYSTEM

erf/minimal_localizations

언어별 번역 매핑을 기반으로 Flutter 앱을 현지화하세요.

minimal_localizations 프로젝트 이미지
Stars
1
Forks
0
최근 푸시(UTC)
2025. 7. 7.
프로젝트 상태
활성
Erlend GitHub avatar
GITHUB User

Erlend ↗

언어C++DartCMakeHTMLSwiftCKotlinObjective-C

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_localizations개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^6.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

minimal_localizations

Localize your Flutter app by providing a map of translations per language, along with methods to retrieve values, strings, and supported locales.

Based on the minimal localization example.

Features

  • Ideal for small projects
  • Easy to use without code generation
  • No need for assets, just pure code
  • Fast performance without asset parsing
  • Supports both String and dynamic types
  • Automatically generates supported locales
  • No external dependencies

Install

Add minimal_localizations and flutter_localizations as dependencies to your pubspec.yaml.

dependencies:
  flutter_localizations:
    sdk: flutter
  minimal_localizations:
Add translations per language

Declare MinimalLocalizationsDelegate given a map of translations per language tag.

Language tags must be valid Unicode BCP47

final minimalLocalizationsDelegate = MinimalLocalizationsDelegate({
  'en': {
    'title': 'Localizations',
    'hello': 'Hello',
  },
  'nb-NO': {
    'title': 'Lokaliseringer',
    'hello': 'Hei',
  },
});

Add localizationDelegates and set supportedLocales.

MaterialApp(
  localizationsDelegates: [
    // global delegates
    ...GlobalMaterialLocalizations.delegates,
    // minimal localizations delegate
    minimalLocalizationsDelegate,
  ],
  supportedLocales: minimalLocalizationsDelegate.supportedLocales,
}
Note on iOS

Add supported languages to ios/Runner/Info.plist as described here

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en</string>
	<string>nb-NO</string>
</array>
API

Translate dynamic values using

MinimalLocalizations.of(context).value('some_value')

Translate String values using

MinimalLocalizations.of(context).string('Hi')

We keep the API minimal, but you can easily add an extension method to String like this:

extension LocalizedString on String {
  String tr(BuildContext context) => MinimalLocalizations.of(context).string(this);
}

So you can translate String values like this:

'Hi'.tr(context)

Example

See example