GoogleSpreadSheetLocalize class

Annotation for automatic creation of multilingualization codes based on Google spreadsheets.

Prepare a Google Spreadsheet in advance by following the steps below.

  1. You can find the spreadsheet from template here on your Copy it to your Google Drive.
    • You can copy from File -> Make a copy.
  2. In the copied spreadsheet, click File -> Share -> Share with others.
  3. In the Share "(the name of the spreadsheet you created)" window, change General access to Anyone with the link.
  4. Copy the URL displayed in your browser (e.g., https://docs.google.com/spreadsheets/d/1bw7IXEr7BGkZ4U6on0OuF7HQkTMgDSm6u5ThpBkDPeo/edit#gid=551986808) and paste it into this and paste it into the url field of this annotation.

You can use the functionality for multilingualization by creating a class that inherits from _$AppLocalize with annotations as shown in the example below.

You can also explicitly update the translation by changing the number of version.

If version is not changed, the spreadsheet contents are cached.

Googleスプレッドシートを元に多言語化コードを自動作成するためのアノテーションです。

事前に下記の手順でGoogleスプレッドシートの準備を行います。

  1. こちらのテンプレートからスプレッドシートを自分のGoogleドライブにコピーします。
    • ファイル -> コピーの作成からコピーが可能です。
  2. コピーしたスプレッドシート内でファイル -> 共有 -> 他のユーザーと共有をクリックします。
  3. (作成したスプレッドシート名)を共有ウィンドウ内で、一般的なアクセスリンクを知っている全員に変更します。
  4. ブラウザで表示されているURL(例:https://docs.google.com/spreadsheets/d/1bw7IXEr7BGkZ4U6on0OuF7HQkTMgDSm6u5ThpBkDPeo/edit#gid=551986808)をコピーしこのアノテーションのurlに貼り付けます。

下記の例のようにアノテーションを付与して_$AppLocalizeを継承したクラスを作成することで多言語化用の機能を利用することができます。

またversionの数を変更することにより明示的に翻訳内容を更新することができます。

versionを変更しない場合はスプレッドシートの内容がキャッシュされます。

@GoogleSpreadSheetLocalize(
  "https://docs.google.com/spreadsheets/d/1bw7IXEr7BGkZ4U6on0OuF7HQkTMgDSm6u5ThpBkDPeo/edit#gid=551986808",
  version: 1,
)
class AppLocalize extends _$AppLocalize {
}

final l = AppLocalize();
Available Extensions

Constructors

GoogleSpreadSheetLocalize(List<String> url, {required int version})
Annotation for automatic creation of multilingualization codes based on Google spreadsheets.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url List<String>
Google Spreadsheet URL.
final
version int
Google Spreadsheet Version.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited