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

套件詳情v0.0.7

localized_rich_text

一個用於簡化 RichText 語系化的 Flutter 插件

AndroidiOSWeb
近 30 天下載
971
喜歡數
7
Pub 分數
140

安裝套件

flutter pub add localized_rich_text

套件介紹

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

一個 Flutter 外掛程式,旨在透過支援佔位符和格式化字串,簡化 RichText 小工具的本地化,實現動態的本地化文字內容。它讓開發者能有效管理多語言富文字,確保跨平台的一致翻譯。該套件與 Flutter 的本地化系統無縫整合,支援 Android、iOS 和 Web。對於需要在多種語言中呈現複雜樣式文字的應用程式特別有用。

適用情境

  • 使用佔位符本地化富文本
  • 支援多語言應用內容
  • 不同語言中的動態文字格式化
  • 與 Flutter 的本地化系統整合
  • 在各種區域設定中顯示樣式文字

主要特色

  • 支援本地化豐富文字中的佔位符
  • 與 Flutter 本地化的無縫整合
  • 跨語言處理格式化文字
  • 跨平台相容性(Android、iOS、Web)
  • 用於豐富文字本地化的簡單 API

適合對象

  • 包含多語言富文本內容的應用程式
  • 使用 Flutter 國際化框架的開發人員
  • 需要動態文字格式化的專案
  • 管理大規模翻譯的團隊
  • 需要一致的UI本地化的Web和移動應用程式

使用建議

  • 需要正確設置Flutter本地化
  • 僅限富文本場景
  • 依賴於正確的翻譯檔案結構
  • 可能需要對複雜的嵌套小部件進行額外處理
  • 不適用於非富文字內容

原始 README

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

A flutter plugin to facilitate the localization of a RichText.

Getting started

Install the library in your pubspec.yaml.

dependencies:
  localized_rich_text: ^0.0.7

Usage

final textToLocalize = "Hi #name, how are you?";
final userName = "Jhon";

final textSpanProperties = TextSpanProperties(
    recognizer: TapGestureRecognizer()
      ..onTap = () {
        //Do something
      },
  );
...
LocalizedRichText(
  text: textToLocalize,
  defaultTextStyle: Theme.of(context).textTheme.bodyText1!,
  keys: [
    LocalizedRichTextKey(
      key: '#name',
      value: userName,
      textStyle: Theme.of(context).textTheme.subtitle1!,
      textSpanProperties: textSpanProperties,
    ),
  ],
)

Parameters explanation

text

This must be the String to localize.
The dynamic values inside the text have to be unique, you can mark them with a special character, or you can use a unique value.

The string could be:

final textToLocalize = "Hi #name, how are you?";

or

AppLocalizations.of(context)!.title,

For more info about internationalization you can check the flutter documentation.

defaultTextStyle

This is the TextStyle used for the static words.

keys

This is the List that has to contain the dynamic values.
Each dynamic value has to be passed like an LocalizedRichTextKey object.
This list cannot be empty.

The keys will be ordered by the order in which they are been inserted in the String to localize.
This means that the order in which you pass the keys inside the keys array isn't important.

LocalizedRichText(
  ...,
  keys: [
    LocalizedRichTextKey(
      key: '#name',
      value: userName,
      textStyle: Theme.of(context).textTheme.subtitle1!,
    ),
  ],
)

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。