搜尋套件、儲存庫與 APP 分類

套件詳情v0.4.1

intl_generator

包含用於處理國際化/本地化訊息、日期和數字格式化與解析、雙向文字以及其他國際化問題的程式碼。

AndroidiOSmacOSWindowsLinux
近 30 天下載
1630
喜歡數
25
Pub 分數
110

安裝套件

flutter pub add intl_generator

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

intl_generator 套件提供程式碼產生工具,以處理 Flutter 應用程式的國際化。它支援本地化訊息、日期與數字格式化、解析,以及雙向文字呈現。透過從訊息檔案產生 Dart 程式碼,它能在不產生執行時間開銷的情況下,實現高效且類型安全的本地化。此套件與 intl 庫無縫整合,讓跨多種語言與平台管理翻譯變得更容易。

適用情境

  • 從 .arb 檔案生成本地化字串
  • 按區域設定格式化日期和數字
  • 支援從右到左的語言
  • 管理多語言應用內容
  • 自動化翻譯工作流程

主要特色

  • 從 ARB 檔案產生程式碼
  • 類型安全的本地化
  • 內建的複數支援
  • 與 intl 庫整合
  • 平台無關的本地化

適合對象

  • 面向全球受眾的Flutter應用
  • 管理多語言翻譯的團隊
  • 需要高性能量化本地化的專案
  • 使用 ARB 進行訊息管理的開發人員
  • 需要一致的日期/數字格式的應用程式

使用建議

  • 需要設置 ARB 檔案
  • 需要建構步驟進行程式碼產生
  • 有限的執行時間自定義
  • 依賴 intl 庫
  • 不適用於動態語言切換

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Intl_generator

This is a fork of intl_translation to have an up to date version.

If you prefer having translations as part of your build_runner process or need to support flavors, please check intl_flavors

This package provides message extraction and code generation from translated messages for the Intl package. It's a separate package so as to not require a dependency on analyzer for all users.

Extracting And Using Translated Messages

When your program contains messages that need translation, these must be extracted from the program source, sent to human translators, and the results need to be incorporated.

To extract messages, run the extract_to_arb.dart program.

  pub run intl_generator:extract_to_arb --output-dir=target/directory
      my_program.dart more_of_my_program.dart

This will produce a file intl_messages.arb with the messages from all of these programs. This is an ARB format file which can be used for input to translation tools like Localizely or (the deprecated) Google Translator Toolkit. The resulting translations can be used to generate a set of libraries using the generate_from_arb.dart program.

This expects to receive a series of files, one per locale.

pub run intl_generator:generate_from_arb --generated-file-prefix=<prefix>
    <my_dart_files> <translated_ARB_files>

This will generate Dart libraries, one per locale, which contain the translated versions. Your Dart libraries can import the primary file, named <prefix>messages_all.dart, and then call the initialization for a specific locale. Once that's done, any Intl.message calls made in the context of that locale will automatically print the translated version instead of the original.

import "my_prefix_messages_all.dart";
...
initializeMessages("dk").then(printSomeMessages);

Once the Future returned from the initialization call completes, the message data is available.

所屬分類

依賴

依賴清單 7 項

原始碼儲存庫

使用此套件的專案