poe2arb

command module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

poe2arb

Latest GitHub release CI status(main branch)

poe2arb is a CLI tool that lets the POEditor work with Flutter's native localization solution (flutter gen-l10n).

Installation

You can download latest or historical binary straight from the GitHub releases artifacts or using Homebrew:

brew tap leancodepl/poe2arb
brew install poe2arb

Usage

poe2arb operates on POEditor's JSON (not JSON key-value) export file format.

TL;DR: Use poe2arb poe command for a seamless integration.

Conversion

poe2arb convert command only converts the POE export to ARB format. Refer to Supported features section.

For conversion, you need to pass the translation file language in the --lang/-l flag.

By default, a template ARB file is generated. So no empty message is skipped and attributes are generated. If you want to skip that, pass --no-template flag.

Currently, only an stdin/stdout is supported for the poe2arb convert command.

stdin/stdout
poe2arb convert io --lang en < Hello_World_English.json > lib/l10n/app_en.arb
Full POEditor integration

poe2arb poe command is your Swiss Army Knife enabling integrating POEditor into your Flutter workspace in one command:

  1. Fetches all project languages from API.
  2. Downloads JSON exports for all languages from API.
  3. Converts JSON exports to ARB format.
  4. Saves converted ARB files to the output directory.
Options
Flag Description Default
-p, --project-id Required. POEditor project ID. It is visible in the URL of the project on POEditor website. Defaults to poeditor-project-id from l10n.yaml file. If it's empty, then defaults to POEDITOR_PROJECT_ID env.
-t, --token Required. POEditor API read-only access token. Available in Account settings > API access. Defaults to POEDITOR_TOKEN env.
-o, --output-dir ARB files output directory. Defaults to arb-dir from l10n.yaml. If it's empty, then defaults to ..
--langs Exported languages override. Defaults to empty, no override.

Syntax & supported features

Term name must be a valid Dart field name, additionaly, it must start with a lowercase letter (Flutter's constraint).

Placeholders

Placeholders are created by putting a text between brackets inside a term. Placeholder name must be a valid Dart parameter name.

Example:

Hello, {name}!

Placeholders have an Object type and are displayed using toString(). An exception for that is the count placeholder when the term is plural, which has an int type.

Plurals

POEditor plurals are also supported. Simply mark the the term as plural and give it any name (it's never used, but required by POEditor to enable plurals for the term).

In translations, a {count} placeholder (num formatted as decimalPattern) can be used. You can use other placeholders too. Example:

one:    Andy has 1 kilogram of {fruit}.
other:  Andy has {count} kilograms of {fruit}.

You must provide at least other plural category for your translations, otherwise it won't be converted.

Contributing

Formatting

We use gofumpt, which is a superset of gofmt.

To make gopls in VS Code use gofumpt, add this to your settings:

"gopls": {
    "formatting.gofumpt": true
},
Linting

We use staticcheck with all checks enabled.

To make VS Code use staticcheck, add this to your settings:

"go.lintTool": "staticcheck",
"go.lintFlags": ["-checks=all"],
Building

All you need is Go 1.19.

go build .
Releasing

Create a lightweight git tag and push it. GitHub Actions with a GoReleaser workflow will take care of the rest.

git tag v0.1.1
git push --tags

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd provides command-line interface commands.
Package cmd provides command-line interface commands.
Package converter handles coversion from POEditor's JSON to Flutter's ARB.
Package converter handles coversion from POEditor's JSON to Flutter's ARB.
Package flutter provides Flutter project configuration and means of parsing it from the filesystem.
Package flutter provides Flutter project configuration and means of parsing it from the filesystem.
Package poeditor handles communication with POEditor API.
Package poeditor handles communication with POEditor API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL