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

パッケージ詳細v0.4.0

language_pickers

Flutterで言語選択ピッカーを自動生成します。さまざまな方法で自由にご利用いただけます。

30日間ダウンロード
62
いいね数
16
Pub ポイント
160

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

flutter pub add language_pickers

パッケージ概要

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

Language Pickers は、言語選択ピッカーの作成を簡素化する Flutter パッケージです。国際化を最小限の努力で実現できる、事前に構築されたカスタマイズ可能なウィジェットを提供しています。柔軟性があり、簡単に統合できるように設計されており、開発者がさまざまな UI コンテキストで言語選択機能を迅速に実装できるようになっています。複数の言語をサポートしており、フォームや設定画面、言語選択が必要な任意のインターフェースで利用可能です。このパッケージはオープンソースであり、個人および商用プロジェクトで自由に利用できます。

用途

  • アプリのローカライゼーション設定
  • ユーザーの言語設定の選択
  • 設定画面言語ピッカー
  • マルチリンガルフォーム入力
  • 国際化アプリインターフェース

主な機能

  • 事前に構築された言語ピッカー・ウィジェット
  • カスタマイズ可能な UI コンポーネント
  • Flutter との簡単な統合
  • 国際化をサポートしています
  • オープンソースで、無料で利用可能

適している対象

  • 多言語アプリを開発する開発者
  • 言語選択ツールを必要とするUIデザイナー
  • 迅速なi18n実装を必要とするプロジェクト
  • Flutter初心者がピッカーを探索しています
  • グローバルなターゲット層向けのアプリ

注意事項

  • 言語切り替えロジックの手動処理が必要
  • 組み込みの翻訳サポートなし
  • UI選択に限定され、言語データ管理ではない
  • 完全なi18nには追加パッケージが必要になる場合があります
  • プラットフォーム固有の動作が明示的に文書化されていない

元の README

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

language_pickers

It's package for Dart and Flutter.

It makes language select pickers for you in Flutter. You can use it freely in lots of ways.

And specially thanks to Figen Güngör(@figengungor), who is opened the source code of 'country_pickers'. Lots of source codes are from country_pickers GitHub Repository, so works are very easy. Thanks again.

Upgrading from 0.3.x

0.4.0 does not break your code. The old API still works, it only warns you. Here is what to move to:

0.3.x 0.4.0
defaultLanguagesList (List<Map<String, String>>) Languages.defaultLanguages (List<Language>)
languagesList: myMaps languages: myLanguages
LanguagePickerUtils.getLanguageByIsoCode('ko') Language.fromIsoCode('ko')
— Languages.korean, Languages.english, …

One behaviour changed: an unknown ISO code now throws an ArgumentError instead of an Exception. ArgumentError is an Error, so on Exception catch no longer catches it.

Every Language also has a nativeName now, and Language implements == and hashCode, so you can put it in a Set or use it as a Map key.

Getting Started

LanguagePickerDropdown example
import 'package:language_pickers/language_pickers.dart';

Language _selectedDropdownLanguage = Language.fromIsoCode('ko');

// It's sample code of Dropdown Item.
// nativeName is the name written in the language itself, e.g. '한국어'.
Widget _buildDropdownItem(Language language) {
  return Row(
    children: <Widget>[
      SizedBox(
        width: 8.0,
      ),
      Text("${language.name} (${language.nativeName})"),
    ],
  );
}


// Builder
LanguagePickerDropdown(
                    initialValue: 'ko',
                    itemBuilder: _buildDropdownItem,
                    onValuePicked: (Language language) {
                      _selectedDropdownLanguage = language;
                      print(_selectedDropdownLanguage.name);
                      print(_selectedDropdownLanguage.isoCode);
                    },
                  ),
Narrowing the languages down
LanguagePickerDropdown(
  languages: const <Language>[
    Languages.korean,
    Languages.english,
    Languages.japanese,
  ],
),
LanguagePickerDropdownController example

The controller lets you read and change the selection from outside the picker.

final controller =
    LanguagePickerDropdownController(initialValue: Languages.korean);

@override
void dispose() {
  controller.dispose();
  super.dispose();
}

// Builder
LanguagePickerDropdown(controller: controller),

// Somewhere else
controller.selectIsoCode('ja');   // the dropdown follows
print(controller.value.name);     // reads the current selection
LanguagePickerDialog example
import 'package:language_pickers/language_pickers.dart';

Language _selectedDialogLanguage =
      Language.fromIsoCode('ko');

// It's sample code of Dialog Item.
Widget _buildDialogItem(Language language) => Row(
    children: <Widget>[
      Text(language.name),
      SizedBox(width: 8.0),
      Flexible(child: Text("(${language.isoCode})"))
    ],
  );

void _openLanguagePickerDialog() => showDialog(
    context: context,
    builder: (context) => Theme(
        data: Theme.of(context).copyWith(primaryColor: Colors.pink),
        child: LanguagePickerDialog(
            titlePadding: EdgeInsets.all(8.0),
            searchCursorColor: Colors.pinkAccent,
            searchInputDecoration: InputDecoration(hintText: 'Search...'),
            isSearchable: true,
            title: Text('Select your language'),
            onValuePicked: (Language language) => setState(() {
                  _selectedDialogLanguage = language;
                  print(_selectedDialogLanguage.name);
                  print(_selectedDialogLanguage.isoCode);
                }),
            itemBuilder: _buildDialogItem)),
  );
LanguagePickerCupertino example
import 'package:language_pickers/language_pickers.dart';

Language _selectedCupertinoLanguage = Language.fromIsoCode('ko');

// It's sample code of Cupertino Item.
void _openCupertinoLanguagePicker() => showCupertinoModalPopup<void>(
  context: context,
  builder: (BuildContext context) {
    return LanguagePickerCupertino(
      pickerSheetHeight: 200.0,
      onValuePicked: (Language language) => setState(() {
            _selectedCupertinoLanguage = language;
            print(_selectedCupertinoLanguage.name);
            print(_selectedCupertinoLanguage.isoCode);
          }),
    );
  });

Widget _buildCupertinoItem(Language language) => Row(
    children: <Widget>[
      Text("+${language.name}"),
      SizedBox(width: 8.0),
      Flexible(child: Text(language.name))
    ],
  );

Information

If a name or a native name is wrong, please make some issues on GitHub.

The names and the native names are based on the public ISO 639-1 code table. Where the table lists several native writings for one language, this package keeps one representative writing, so that it fits in a dropdown.

Credits

Developed by gomgom(GitHub @gomgom).

カテゴリー

ソースリポジトリ

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

データはまだありません。