0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Copilotを活用して効率よくFlutterプロジェクト多言語対応

Posted at

前言

お正月の間にFlutterを勉強してappを作ってみた。
一番感心したのはCopilotの活用でとても効率アップできたこと。
今回は一つの例として、多言語対応のやり方を共有させていただく。

Flutterプロジェクト多言語対応時、Copilotの活用方法

まとめて言うと、Copilotに多言語のリソースファイルを作成してもらうこと。

1.多言語パッケージをインストールする

VSCodeのTerminal
flutter pub add flutter_localizations --sdk=flutter
flutter pub add intl:any

2.pubspec.yamlで自動生成フラグをONにする

# The following section is specific to Flutter.
flutter:
  generate: true # Add this line

3.多言語設定ファイルl10n.yamlを作成する

l10n.yaml
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-dir: lib/l10n
synthetic-package: false

4.${FLUTTER_PROJECT}/lib/l10n/app_en.arbを作成する

5.VSCodeのメニュー「View>Copilot Edits」AIとの会話画面を開いて、
「app_en.arbを参照して、ar,de,es,fr,ja,zh・・・のarbを作成してください」をCopilotに伝えて、
他言語のarbファイルを作成してもらう。

6.多言語のファイルを生成する

VSCodeのTerminal
flutter gen-l10n

これで簡単に多言語対応が出来上がり!
※リソースの使用方法は説明していないけど、以下のサイトをご参照ください。
公式サイト:Internationalizing Flutter apps

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?