こんにちはジョージです。FileMaker Pro 20.2.1 で追加された新機能「レイアウト計算」を使って多言語対応をしてみるよ!
ファイルの準備
今日使うファイルは、FileMaker Pro のスターターソリューション「資産」をベースに修正を加えます。まずは新規ファイル作成から「資産」を選択して任意の場所にファイルを保存します。

言語ラベルの準備
今日は日本語、英語、韓国語の 3 つを対象に言語ラベルを作成します。新規スクリプトを作成して JSON を使った各国の言語ラベルを作成していきます。
言語ラベルは、Get (アプリケーション言語) から取得した「アプリケーションの現在の言語を示すテキスト」か、任意に指定した「言語テキスト」のどちらかが選択され、グローバル変数 $$lz に保存されます。

# #
#
変数を設定 [ $lz ; 値: "{}" ]
#
# Name
Type
Purchase Date
Price
Used By
Description
Serial Number
Vendor
変数を設定 [ $label ; 値: JSONSetElement ( "{}"; [ "Title"; "ASSET"; JSONString ]; [ "Name"; "Name"; JSONString ]; [ "Type"; "Type"; JSONString ]; [ "Purchase Date"; "Purchase Date"; JSONString ]; [ "Price"; "Price"; JSONString ]; [ "Used By"; "Used By"; JSONString ]; [ "Descript… ]
変数を設定 [ $lz ; 値: JSONSetElement ( $lz; "English"; $label; JSONObject ) ]
#
# 名前
タイプ
購入日
価格
使用者
説明
シリアル番号
購入元
変数を設定 [ $label ; 値: JSONSetElement ( "{}"; [ "Title"; "資産"; JSONString ]; [ "Name"; "名前"; JSONString ]; [ "Type"; "タイプ"; JSONString ]; [ "Purchase Date"; "購入日"; JSONString ]; [ "Price"; "価格"; JSONString ]; [ "Used By"; "使用者"; JSONString ]; [ "Description"; "説明"; JSONString … ]
変数を設定 [ $lz ; 値: JSONSetElement ( $lz; "Japanese"; $label; JSONObject ) ]
#
# 이름
유형
구입 날짜
가격
사용한 사람
설명
일련번호
판매 회사
変数を設定 [ $label ; 値: JSONSetElement ( "{}"; [ "Title"; "자산"; JSONString ]; [ "Name"; "이름"; JSONString ]; [ "Type"; "유형"; JSONString ]; [ "Purchase Date"; "구입 날짜"; JSONString ]; [ "Price"; "가격"; JSONString ]; [ "Used By"; "사용한 사람"; JSONString ]; [ "Description"; "설명"; JSONStr… ]
変数を設定 [ $lz ; 値: JSONSetElement ( $lz; "Korean"; $label; JSONObject ) ]
#
# Get (アプリケーション言語)
https://help.claris.com/ja/pro-help/content/get-applicationlanguage.html ➜🌏
#
変数を設定 [ $param ; 値: Get( スクリプト引数 ) ]
変数を設定 [ $lang ; 値: If ( IsEmpty ( $param ); Get( アプリケーション言語 ); $param ) ]
変数を設定 [ $$lz ; 値: JSONGetElement ( $lz; $lang ) ]
#
#
#
#
#
ラベルに「レイアウト計算」を適用する
多言語したいラベルに「レイアウト計算」を適用していきます。挿入メニューから新規に追加するか、テキストを選択してからレイアウト計算を編集することで、計算式で指定した結果をレイアウトに表示できます。マージ変数と違って、いちいち変数に代入する事なく計算結果が使えるので、非常に便利になりました。欲を言えば「レイアウト計算」のなかで「Self」が使えるとさらに応用ができるのですが、執筆時点では非対応でした。



言語切り替えスクリプトの作成
準備が完成したら言語切り替えスクリプトを作成し実行してみます。まずは英語から………


おぉ!ラベルが英語に切り替わりました。次は韓国語………

ジャ〜ン!ラベルが韓国語になりました。

最後に、ファイルを開いた際はアプリケーションの言語が選択されるように OnFirstWindowOpen に起動スクリプトの割り当てを行います。

まとめ
いかがでしたでしょうか?FileMaker Pro 20.2.1 で追加された新機能「レイアウト計算」を応用して、レイアウトの多言語化を行ってみました。従来よりもすっきりと実装ができたような気がします。最新バージョンにアップデートして、ぜひこの便利な機能を使ってみてください!