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

패키지 상세v2.8.17

intl_utils

intl_utils는 ARB 파일에서 Dart 로컬라이제이션 코드를 생성하는 Dart 라이브러리입니다. 생성된 코드는 Intl 라이브러리에 의존합니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
36만
좋아요
243
Pub 점수
150

패키지 설치

flutter pub add intl_utils

패키지 개요

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

intl_utils는 ARB(App Resource Bundle) 파일에서 로컬라이제이션 코드를 자동으로 생성하는 Dart 라이브러리로, 국제화를 위해 Intl 라이브러리를 활용합니다. 지역화된 문자열을 타입 안전한 Dart 코드로 변환함으로써 번역 워크플로우를 간소화하고 수작업과 잠재적인 오류를 줄입니다. 다국어 지원이 필요한 Flutter 프로젝트에 적합하며 기존의 로컬라이제이션 설정과 원활하게 통합되며 모든 주요 플랫폼을 지원합니다. 이 도구는 번역을 소스 코드와 동기화함으로써 개발자의 생산성을 향상시킵니다.

사용 사례

  • 로컬라이제이션 코드 생성 자동화
  • Flutter 앱에 ARB 파일 통합하기
  • 다국어 콘텐츠 관리
  • 번역 워크플로우 간소화
  • CI/CD 로컬라이제이션 파이프라인 지원

주요 기능

  • 형 안전한 로컬라이제이션 클래스 생성
  • 내부에서 Intl 라이브러리를 사용합니다
  • ARB 파일 입력을 지원합니다
  • 번역 관리를 간소화합니다
  • 플랫폼 전체 로컬라이제이션 활성화

적합한 대상

  • ARB 파일을 사용하는 Flutter 개발자
  • 다중 언어를 관리하는 팀
  • 자주 번역이 업데이트되는 프로젝트
  • CI/CD 통합 로컬라이제이션 워크플로우
  • 글로벌 청중을 대상으로 하는 앱

고려 사항

  • ARB 파일이 올바르게 형식화되어 있어야 합니다
  • 런타임 기능을 위해 Intl 라이브러리에 의존합니다
  • 초기 구성에 대한 수동 설정이 필요합니다
  • 구조화된 번역 워크플로와 함께 사용하는 것이 가장 좋습니다
  • ARB 기반 로컬라이제이션에 제한됨

원본 README

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

Intl Utils

pub package Twitter Follow

Dart package that creates a binding between your translations from .arb files and your Flutter app. It generates boilerplate code for official Dart Intl library and adds auto-complete for keys in Dart code.

Usage

You can use this package directly (i.e. for Continuous Integration tools or via CLI) or leave it to Visual Studio Code or IntelliJ/Android Studio plugins to run it automatically whenever you modify ARB files.

Follow these steps to get started:

Configure package

Add package configuration to your pubspec.yaml file. Here is a full configuration for the package:

flutter_intl:
  enabled: true # Required. Must be set to true to activate the package. Default: false
  class_name: S # Optional. Sets the name for the generated localization class. Default: S
  main_locale: en # Optional. Sets the main locale used for generating localization files. Provided value should consist of language code and optional script and country codes separated with underscore (e.g. 'en', 'en_GB', 'zh_Hans', 'zh_Hans_CN'). Default: en
  arb_dir: lib/l10n # Optional. Sets the directory of your ARB resource files. Provided value should be a valid path on your system. Default: lib/l10n
  output_dir: lib/generated # Optional. Sets the directory of generated localization files. Provided value should be a valid path on your system. Default: lib/generated
  use_deferred_loading: false # Optional. Must be set to true to generate localization code that is loaded with deferred loading. Default: false
  localizely: # Optional settings if you use Localizely platform. Read more: https://localizely.com/blog/flutter-localization-step-by-step/?tab=automated-using-flutter-intl
    project_id: # Get it from the https://app.localizely.com/projects page.
    branch: # Get it from the “Branches” page on the Localizely platform, in case branching is enabled and you want to use a non-main branch.
    upload_overwrite: # Set to true if you want to overwrite translations with upload. Default: false
    upload_as_reviewed: # Set to true if you want to mark uploaded translations as reviewed. Default: false
    upload_tag_added: # Optional list of tags to add to new translations with upload (e.g. ['new', 'New translation']). Default: []
    upload_tag_updated: # Optional list of tags to add to updated translations with upload (e.g. ['updated', 'Updated translation']). Default: []
    upload_tag_removed: # Optional list of tags to add to removed translations with upload (e.g. ['removed', 'Removed translation']). Default: []
    download_empty_as: # Set to empty|main|skip, to configure how empty translations should be exported from the Localizely platform. Default: empty
    download_include_tags: # Optional list of tags to be downloaded (e.g. ['include', 'Include key']). If not set, all string keys will be considered for download. Default: []
    download_exclude_tags: # Optional list of tags to be excluded from download (e.g. ['exclude', 'Exclude key']). If not set, all string keys will be considered for download. Default: []
    ota_enabled: # Set to true if you want to use Localizely Over-the-air functionality. Default: false
Add ARB files

Add one ARB file for each locale you need to support in your Flutter app. Add them to lib/l10n folder inside your project, and name them in a following way: intl_<LOCALE_ISO_CODE>.arb.
For example: intl_en.arb or intl_en_GB.arb. You can also change the ARB folder from lib/l10n to a custom directory by adding the arb_dir line in your pubspec.yaml file.

If you wonder how to format key-values content inside ARB files, here is detailed explanation.

Run command

To generate boilerplate code for localization, run the generate program inside directory where your pubspec.yaml file is located:

  dart run intl_utils:generate

This will produce files inside lib/generated directory. You can also change the output folder from lib/generated to a custom directory by adding the output_dir line in your pubspec.yaml file.

Integration with Localizely
Upload main ARB file
  dart run intl_utils:localizely_upload_main [--project-id <PROJECT_ID> --api-token <API_TOKEN> --arb-dir <ARB_DIR> --main-locale <MAIN_LOCALE> --branch <BRANCH> --[no-]upload-overwrite --[no-]upload-as-reviewed] --upload-tag-added <UPLOAD_TAG_ADDED> --upload-tag-updated <UPLOAD_TAG_UPDATED> --upload-tag-removed <UPLOAD_TAG_REMOVED>

This will upload your main ARB file to Localizely.
All args are optional. If not provided, the intl_utils will use configuration from the pubspec.yaml file or default values (check the Configure package section for more details).

Download ARB files
  dart run intl_utils:localizely_download [--project-id <PROJECT_ID> --api-token <API_TOKEN> --arb-dir <ARB_DIR> --download-empty-as <DOWNLOAD_EMPTY_AS> --download-include-tags <DOWNLOAD_INCLUDE_TAGS> --download-exclude-tags <DOWNLOAD_EXCLUDE_TAGS> --branch <BRANCH>]

This will download all available ARB files from the Localizely platform and put them under arb-dir folder.
All args are optional. If not provided, the intl_utils will use configuration from the pubspec.yaml file or default values (check the Configure package section for more details).

Notes:
Argument project-id can be omitted if pubspec.yaml file contains project_id configuration under flutter_intl/localizely section.
Argument api-token can be omitted if ~/.localizely/credentials.yaml file contains api_token configuration (e.g. api_token: xxxxxx).
Optional argument arb-dir has the value lib/l10n as default and needs only to be set, if you want to place your ARB files in a custom directory.

카테고리

의존성

의존성 목록 9 개

소스 저장소

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