lang_table

lang_table is a dart plugin to generate string files from a source. Use a table to manage all multi-language resources. Inspired by fetch-mobile-localization-from-airtable

Installation

Add this library into pubspec.yaml

dev_dependencies: 
    lang_table: 0.1.0

Usage

Run the following command at root directory.Then will generate several output files based on the source platform

pub run lang_table:generate

A below table shown all supported arguments:

ArgumentDescription
--platform(Required) The platform stores all localization strings. Suppoted platforms: airTable
--input(Required) The source of the strings
--target(Required) Code generator for a target plaformat. Supported target: Flutter
--output-dir(Optional) An output folder stores all generated json files (defaults to "res/string")
--api-key(Optional) Usage of platform specific

Example

Key [code=key]English [code=en]Traditional Chinese [code=zh_TW]Japanese [code=ja]
localeEnglish中文日文
simpleMessageThis is a simple Message這是簡單消息これは簡単なメッセージです
messageWithParamsHi ${yourName}, Welcome you!你好 ${yourName},歡迎你。こんにちは${yourName}、ようこそ。

Example Template on AirTable

Running the following command,

pub run lang_table:generate --platform=airTable --input=https://api.airtable.com/v0/appZmh0WMg3y6APAg/example --api-key={YOUR API KEY} --target=Flutter

Generated files like this,

|--- lib 
|--- res 
    |--- string 
         |--- string_en.json 
         |--- string_zh_TW.json 
         |--- string_ja.json 

Meta Code

It is required to insert into table headers for identifying the usage of a table's column.

Type of Meta Code

[code=key]Used to identify the column storing a key for a message
[code={Locale}]Used to identify the column storing a message for a specific language

Supported Platforms

AirTable

Example

pub run lang_table:generate --platform=airTable --input=https://api.airtable.com/v0/appZmh0WMg3y6APAg/example --api-key={YOUR API KEY} --target=Flutter

Libraries

base_platform_generator