패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.1.1

ez_localization

Flutter 앱에서 빠르고 쉽게 강력한 로컬라이제이션 시스템을 설정하세요.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
193
좋아요
23
Pub 점수
150

패키지 설치

flutter pub add ez_localization

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ez_localization은 강력한 로컬라이제이션 시스템을 쉽게 설정할 수 있도록 도와주는 Flutter 패키지로, 개발자가 애플리케이션에 국제화를 빠르게 구현할 수 있게 해줍니다. 여러 언어를 지원하며 Android, iOS, Web, macOS, Windows, Linux에서 번역을 관리하기 위한 직관적인 API를 제공합니다. 최소한의 구성으로 지역 설정 간 원활한 전환과 동적 콘텐츠 처리를 효율적으로 수행할 수 있습니다. 글로벌 사용자를 대상으로 하는 앱에 적합하며, 반복 코드를 줄이고 유연성과 확장성을 유지합니다.

사용 사례

  • 다국어 앱 지원
  • 간편한 번역 관리
  • 동적 로케일 전환
  • 크로스 플랫폼 국제화
  • 간소화된 i18n 설정
  • 글로벌 사용자를 위한 앱 로컬라이제이션

주요 기능

  • 최소한의 설정 필요
  • 모든 주요 플랫폼을 지원합니다
  • 내장된 로케일 전환
  • 깨끗하고 읽기 쉬운 번역 구문
  • 확장 가능한 번역 파일 구조
  • 기본 언어로 자동 백업

적합한 대상

  • 다국어 앱을 개발하는 개발자
  • 번역 워크플로우를 관리하는 팀
  • 빠른 i18n 통합이 필요한 프로젝트
  • 국제 시장을 겨냥한 앱
  • Flutter 초보자가 로컬라이제이션을 배우고 있습니다
  • 자주 언어가 업데이트되는 프로젝트

고려 사항

  • 정확한 번역 파일 구성이 필요합니다
  • 제한된 내장 번역 편집 도구
  • 복잡한 복수형 수동 처리
  • 정확한 지역 설정 이름 규칙에 따라 달라집니다
  • 내장된 번역 저장 또는 동기화 없음
  • 구조화된 번역 파일과 함께 사용하는 것이 가장 좋습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

EzLocalization

This package allows you to setup a powerful localization system with ease and in only a few minutes.

Features

Here are some features:

  • Easy, lightweight, open-source.
  • MIT licensed.
  • Easily extensible.

Getting started

It only takes a few steps in order to get EzLocalization to work !
First, add the following code to your MaterialApp definition (usually in main.dart) :

EzLocalizationDelegate ezLocalization = EzLocalizationDelegate(supportedLocales: [Locale('en'), Locale('fr')]); // The first language is your default language.

return MaterialApp(
  // ...
  localizationsDelegates: ezLocalization.localizationDelegates,
  supportedLocales: ezLocalization.supportedLocales,
  localeResolutionCallback: ezLocalization.localeResolutionCallback,
);

Then you create a folder named languages in your assets directory with the defined languages in it. An example structure could be :

assets
└── languages
    ├── en.json
    └── fr.json

Here's an example of en.json :

{
  "hello": "Hello !"
}

And a translated fr.json :

{
  "hello": "Bonjour !"
}

Don't forget to add the assets in your pubspec.yml :

flutter:
  # ...
  assets:
    - "assets/languages/"

That's it ! To get your string you only have to call EzLocalization.of(context)!.get('hello').

Advanced

Extension method

With the extension method, it's even easier to get a localized string ! The only thing you have to do is to replace EzLocalization.of(context)!.get('key') by context.getString('key').

You may have to manually import EzLocalization in your file.

Builder widget

EzLocalization provides a builder widget called EzLocalizationBuilder. You can use it as such :

const EzLocalizationBuilder(
  delegate: EzLocalizationDelegate(
    supportedLocales: [
      Locale('en'),
      Locale('fr'),
      Locale('es'),
    ],
  ),
  builder: (context, localizationDelegate) => MaterialApp(
    title: 'Beautifully localized app',
    home: MyMainWidget(),
    localizationsDelegates: localizationDelegate.localizationDelegates,
    supportedLocales: localizationDelegate.supportedLocales,
    localeResolutionCallback: localizationDelegate.localeResolutionCallback,
  ),
);

It has two advantages :

  • It helps reducing boilerplate.
  • You can dynamically change the current locale using EzLocalizationBuilder.of(context)!.changeLocale(yourLocale).
Nested strings

You can nest translation strings as such :

{
  "tabs": {
    "home": "Home"
  }
}

And it can be access using EzLocalization.of(context)!.get('tabs.home').

Format arguments

In your translation string, you may add arguments using {} :

{
  "greeting": "Hello {target}, my name is {me} !"
}

You can then fill them with EzLocalization.of(context)!.get('greeting', {'target': 'John', 'me': 'Bob'}). Also, instead of a map you can pass a list and get your arguments by their indexes.

Change the files path

You can change from the default path of assets/languages/$languageCode.json by passing getPathFunction to EzLocalizationDelegate. You will then have to provide a valid asset path according to the specified locale.

Don't forget to update your assets entry in your pubspec !

Updating the iOS app bundle

See the official flutter.dev documentation about updating the iOS app bundle.

Contributing

You have a lot of options to contribute to this project ! You can :

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.