LocalizedValue<T>.fromJson constructor
LocalizedValue<T>.fromJson (
- DynamicMap json
Class for storing translation data.
It consists of a pair of Locale and the corresponding T
for the translation.
LocalizedValue.fromJson can be used to convert String and T
pairs from Json.
In that case, the key must be a string delimited by _
, such as ja_JP
.
Obtains the translation of Locale specified in value.
翻訳データを保存するためのクラス。
Localeとその翻訳に対応するT
のペアで構成されます。
LocalizedValue.fromJsonを利用することでStringとT
のペアのJsonからの変換が可能です。
その場合、キーはja_JP
のように_
で区切られた文字列である必要があります。
Implementation
factory LocalizedValue.fromJson(DynamicMap json) {
return LocalizedValue(
json.toList((key, value) {
final keys = key.replaceAll("-", "_").split("_");
return LocalizedLocaleValue(
Locale(
keys.first,
keys.length > 1 ? keys.last : null,
),
value as T,
);
}),
);
}