パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.4

fluent

Fluent は、自然言語の表現力を引き出すことを目的としたローカリゼーションフレームワークである Project Fluent の Dart 実装です。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2340
いいね数
26
Pub ポイント
130

パッケージをインストール

flutter pub add fluent

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Fluent は、Project Fluent の Dart 実装であり、表現力豊かで文脈に応じた翻訳を可能にする現代的なローカライゼーションフレームワークです。強力な構文により、複雑な文構造、複数形、性別処理をサポートしています。国際化を目的として設計されており、開発者が人間が読みやすい形式でローカライズファイルを記述できるため、開発者と翻訳者の協働を促進します。Android、iOS、Web、macOS、Windows、Linux などの主要プラットフォームすべてで動作し、豊富でダイナミックなコンテンツを必要とするクロスプラットフォームアプリに最適です。

用途

  • マルチリンガルアプリのローカライゼーション
  • コンテキストに応じた翻訳を備えた動的コンテンツ
  • 共同翻訳ワークフロー
  • 複雑な文法ルールのサポート
  • クロスプラットフォーム国際化

主な機能

  • 翻訳における自然言語表現
  • 複数形および性別サポート
  • コンテキストに応じたメッセージフォーマット
  • 人間が読める .ftl ファイル
  • Flutterとのシームレスな統合

適している対象

  • グローバルな視聴者をターゲットにしたアプリ
  • 非技術的な翻訳者を擁するチーム
  • 高度なローカリゼーション論理を必要とするプロジェクト
  • 複数のプラットフォームでのFlutterアプリ
  • 保守可能なi18nを重視する開発者

注意事項

  • Fluentの構文を学ぶ必要がある
  • レガシーフレームワークと比べてツールの選択肢が限られる
  • 大規模なプロジェクトにはカスタムビルド手順が必要になる場合があります
  • 単純なキー値翻訳には適していません
  • 新しいプロジェクトの初期セットアップオーバーヘッド

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Fluent

This is a Dart runtime implementation of Project Fluent, a localization framework designed to unleash the entire expressive power of natural language translations.

Project Fluent keeps simple things simple and makes complex things possible. The syntax used for describing translations is easy to read and understand. At the same time it allows, when necessary, to represent complex concepts from natural languages like gender, plurals, conjugations, and others.

Getting Started

Learn the FTL syntax

FTL is a localization file format used for describing translation resources. FTL stands for Fluent Translation List.

FTL is designed to be simple to read, but at the same time allows to represent complex concepts from natural languages like gender, plurals, conjugations, and others.

hello-user = Hello, { $username }!

In order to use fluent.runtime, you will need to create FTL files. Read the Fluent Syntax Guide <http://projectfluent.org/fluent/guide/>_ in order to learn more about the syntax.

Using FluentBundle

Once you have some FTL files, you can generate translations using the fluent package. You start with the FluentBundle class:

import 'package:fluent/fluent.dart';

You pass a locale to the constructor:

final bundle = FluentBundle('en-GB');

You must then add messages. These would normally come from a .ftl file stored on disk, here we will just add them directly:

bundle.addMessages('''
welcome = Welcome to this great app!
greet-by-name = Hello, { $name }!
''');

To generate translations, use the format method, passing a message ID and an optional dictionary of substitution parameters. If the the message ID is not found, null is returned. Otherwise, as per the Fluent philosophy, the implementation tries hard to recover from any formatting errors and generate the most human readable representation of the value.

List<Error> errors = [];
translated = bundle.format('welcome', errors: errors)
translated = bundle.format('greet-by-name', args: {'name': 'Jane'}, errors: errors)

Custom functions

Besides the built-in NUMBER and DATETIME functions, you can register your own functions for use in translations, e.g. a PLATFORM() function used to pick a variant based on the current OS:

FluentValue platform() => FluentString('macos');
final bundle = FluentBundle('en-GB', functions: {'PLATFORM': platform});

bundle.addMessages('''
settings-menu-label = { PLATFORM() ->
    [macos] Preferences
   *[other] Settings
}
''');

A custom function receives its FTL positional and named arguments as plain Dart values (already unwrapped from FluentValue, e.g. String/num/ DateTime), and must return a FluentValue (e.g. FluentString, FluentNumber). Custom functions may also override the built-in NUMBER and DATETIME functions by registering under those names.

Known limitations and bugs

  • We do not yet support NUMBER(..., currencyDisplay="...", minimumSignificantDigits="...", maximumSignificantDigits=".. ")

  • Most options to DATETIME are not yet supported.

Help with the above would be welcome!

カテゴリー

依存関係

依存関係一覧 1 件

  • intl>=0.19.0 <0.21.0

ソースリポジトリ

このパッケージを使用しているプロジェクト