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

패키지 상세v0.6.0

multiple_localization

intl 패키지용 다중 abr 및 메시지 로컬라이제이션 파일 지원.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.5만
좋아요
28
Pub 점수
160

패키지 설치

flutter pub add multiple_localization

패키지 개요

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

multiple_localization 패키지는 .arb 파일을 포함한 여러 로컬라이제이션 파일을 지원함으로써 intl 패키지를 강화하여 개발자가 다양한 언어와 지역 설정 간의 번역을 보다 효율적으로 관리할 수 있도록 합니다. 대규모 국제화 요구 사항을 처리할 때 특히 유용한 Flutter 앱에서 로컬라이즈된 메시지를 조직하고 로드하는 과정을 단순화합니다. 이 패키지는 Flutter의 기존 국제화 인프라와 원활하게 작동하도록 설계되어 번역 자산의 유지 및 확장이 더 쉬워집니다. 모든 주요 플랫폼(Android, iOS, Web, macOS, Windows, Linux)을 지원합니다.

사용 사례

  • 단일 프로젝트에서 여러 언어 파일 관리하기
  • 대규모 앱을 위한 번역 워크플로우 간소화
  • 동적 로케일 전환 지원
  • 기능 또는 모듈별로 번역 정리하기
  • 기존 intl 기반 로컬라이제이션과의 통합
  • 모듈형 로컬라이제이션 구조 활성화

주요 기능

  • 여러 .arb 파일 지원
  • intl 패키지와의 원활한 통합
  • 유연한 파일 조직
  • 플랫폼에 관계없는 설계
  • pub add를 통한 간편 설정
  • 자동 메시지 로드

적합한 대상

  • 대규모 국제화 플러터 애플리케이션
  • 여러 번역 파일을 관리하는 팀
  • 모듈식 현지화가 필요한 프로젝트
  • 국제화를 위해 intl을 사용하는 개발자
  • 다양한 글로벌 청중을 대상으로 하는 앱

고려 사항

  • intl 패키지에 익숙해야 합니다
  • 사용자 지정 파일 경로를 위한 추가 구성이 필요합니다
  • 많은 파일로 인해 빌드 복잡성이 증가할 수 있습니다
  • 기존에 intl을 사용하는 프로젝트에 가장 적합
  • 비국제화 현지화 접근 방식과 호환되지 않음

원본 README

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

multiple_localization

pub package Analyze & Test innim lint

Support for multiple abr and messages localization files for intl package.

Problem

If you want to have multiple arb files and register separate delegate for each one of them, then you have a problem. Intl doesn't allow multiple initializeMessages calls. Only first one will be processed and only it's messages will be used. Every calls after the first one will be ignored.

Why do we need to have multiple arb files?

In common scenario - we don't. Just put all localization string in single file and enjoy. But if you want to add intl localization with arb files to separate package, and than use it in you project with it's own localization files - that's problem.

MultipleLocalizations supports using Localizations.override(delegates: [SomeLocalizationsDelegate(), ...]) widget, too.

Exactly for that situation this package was developed.

See article on Medium for more details - Localization for Dart package.

Usage

To use this package, add multiple_localization as a dependency in your pubspec.yaml file.

Than use MultipleLocalizations.load for your delegate load function, instead of call initializeMessages explicitly.

Example
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
  const _AppLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) {
    return ['en', 'ru'].contains(locale.languageCode);
  }

  @override
  Future<AppLocalizations> load(Locale locale) {
    return MultipleLocalizations.load(
        initializeMessages, locale, (l) => AppLocalizations(l),
        setDefaultLocale: true);
  }

  @override
  bool shouldReload(LocalizationsDelegate<AppLocalizations> old) {
    return false;
  }
}
Override string from package in project

If you want to override string from package localization in project (for example to change some labels in package widgets) - you need to define string with required name in you app localization class.

Example.

If package has string messageFromPackageForOverride:

class PackageLocalizations {
  ...

  String get messageFromPackageForOverride =>
        Intl.message('Package', name: 'messageFromPackageForOverride');

Then you need to define messageFromPackageForOverride in you AppLocalizations:

class AppLocalizations {
  ...

  String get messageFromPackageForOverride =>
        Intl.message('App', name: 'messageFromPackageForOverride');

Make sure that you add the app localization delegate before the package localization delegate:

  ...
  const MaterialApp(
    localizationsDelegates: [
      AppLocalizations.delegate,
      PackageLocalizations.delegate,
      ...
    ],
    ...

Now, whenever package use messageFromPackageForOverride you will see App, not Package.

Set fallback locale

Also you can specify a fallback locale when loading application localization delegate. Use [fallbackLocale] parameter to set locale which will be used if some key not found for current locale. Only first call of [load] will set fallback locale, make sure that your app's localization delegate added as a first element of the delegates list.

Also pay attention that if you provide the [fallbackLocale], than all messages will be uploaded in memory on the start of application in addition to current locale.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.