Search packages, repositories and app categories

Package detailsv0.0.7

localized_rich_text

A flutter plugin to facilitate the localization of a RichText

AndroidiOSWeb
30-day downloads
971
Likes
7
Pub points
140

Install package

flutter pub add localized_rich_text

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin designed to simplify the localization of RichText widgets by enabling dynamic, localized text content with support for placeholders and formatted strings. It allows developers to manage multilingual rich text efficiently, ensuring consistent translations across platforms. The package integrates seamlessly with Flutter’s localization system and supports Android, iOS, and Web. It is particularly useful for apps requiring complex, styled text in multiple languages.

Use cases

  • Localizing rich text with placeholders
  • Supporting multilingual app content
  • Dynamic text formatting in different languages
  • Integrating with Flutter's localization system
  • Displaying styled text in various locales

Key features

  • Supports placeholders in localized rich text
  • Seamless integration with Flutter localization
  • Handles formatted text across languages
  • Cross-platform compatibility (Android, iOS, Web)
  • Simple API for rich text localization

Suitable for

  • Apps with multilingual rich text content
  • Developers using Flutter's localization framework
  • Projects requiring dynamic text formatting
  • Teams managing large-scale translations
  • Web and mobile applications needing consistent UI localization

Considerations

  • Requires proper setup of Flutter localization
  • Limited to rich text scenarios
  • Depends on correct translation file structure
  • May need additional handling for complex nested widgets
  • Not suitable for non-rich text content

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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!,
    ),
  ],
)

Categories

Source repository

Projects using this package

No data available yet.