arb_tooling 0.0.7 copy "arb_tooling: ^0.0.7" to clipboard
arb_tooling: ^0.0.7 copied to clipboard

A Dart tool to translate from CSV to ARB and viceversa. It can fetch the CSV file from URL too.

ARB Tooling #

ARB Tooling Logo

Developed with 💙 by Raul Mabe

style: very good analysis License: MIT

Dart tool to convert from ARB to CSV and viceversa.


Considerations and restrictions about the CSV file #

  • Field delimiter must be ,.
  • Key must be column with index 0.
  • Description is mandatory (empty cells will be ignored when generating ARB) and must be column with index 1.
  • Base language must be column with index 2.
  • eol must be \r\n.

Check /example folder to see the formatted files.

Installing #

If the CLI application is available on pub, activate globally via:

dart pub global activate arb_tooling

Or locally via:

dart pub global activate --source=path <path to this package>

Or execute the binary (bin/arb_tooling.exe); which can be generated via:

dart compile exe bin/arb_tooling.dart

Features and usage #

  • ✅ Convert from ARB files to CSV file
# To CSV command
$ dart ./bin/arb_tooling.dart to_csv -i example/input/arb -o example/output
  • ✅ Convert from CSV file to ARB files
# From CSV command
$ dart ./bin/arb_tooling.dart from_csv -i example/input/csv/translations.csv -o example/output -p app_
  • ✅ Convert from CSV file hosted in URL to ARB files
# From CSV command -> URL
$ dart ./bin/arb_tooling.dart from_csv -u https://docs.google.com/spreadsheets/d/{sheet_id}/export\?format\=csv\&id\={sheet_id}\&gid\={gid} -o example/output -p app_
  • ✅ Rename files and directory names recursively inside a directory
# File rename
$ dart ./bin/arb_tooling.dart file_rename -i ./lib/src/models --from-name settings --to-name config
  • More
# Show CLI version
$ arb_tooling --version

# Show usage help
$ arb_tooling --help

Example files #

A CSV file of the form

key description en es
hello Hello world Hello world! Hola mundo!
placeholder Example of placeholder Hello {name} Hola {name}
plural Example of plural {number,plural, =0{Sold out} =1{1 spot left} other{{number} spots left}} {number,plural, =0{Agotadas} =1{1 plaza libre} other{{number} plazas libres}}
endOfLine Example of end of line Enter it below to verify it.\r\nCheck your spam folder as well. Introducelo para verificar.\r\nMira la carpeta de spam también.

generates the following ARB files

en.arb
{
  "@@locale": "en",
  "hello": "Hello world!",
  "@hello": {
    "description": "Hello world"
  },
  "placeholder": "Hello {name}",
  "@placeholder": {
    "description": "Example of placeholder",
    "placeholders": {
      "name": {}
    }
  },
  "plural": "{number,plural, =0{Sold out} =1{1 spot left} other{{number} spots left}}",
  "@plural": {
    "description": "Example of plural",
    "placeholders": {
      "number": {}
    }
  },
  "endOfLine": "Enter it below to verify it.\nCheck your spam folder as well.",
  "@endOfLine": {
    "description": "Example of end of line"
  }
}
es.arb
{
  "@@locale": "es",
  "hello": "Hola mundo!",
  "@hello": {
    "description": "Hello world"
  },
  "placeholder": "Hola {name}",
  "@placeholder": {
    "description": "Example of placeholder",
    "placeholders": {
      "name": {}
    }
  },
  "plural": "{number,plural, =0{Agotadas} =1{1 plaza libre} other{{number} plazas libres}}",
  "@plural": {
    "description": "Example of plural",
    "placeholders": {
      "number": {}
    }
  },
  "endOfLine": "Introducelo para verificar.\nMira la carpeta de spam también.",
  "@endOfLine": {
    "description": "Example of end of line"
  }
}

This ARB file can then be converted into localization delegates using intl or intl_utils.

Note This process can also be reversed via the to_csv commmand.

3
likes
120
pub points
17%
popularity

Publisher

verified publisherraulmabe.dev

A Dart tool to translate from CSV to ARB and viceversa. It can fetch the CSV file from URL too.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

args, csv, mason_logger, meta, pub_updater

More

Packages that depend on arb_tooling