accent/cli
2023-02-27 14:01:31 -05:00
..
bin Add cli in the repo to truly become a MONOREPO 🎉 2019-03-04 17:16:50 -05:00
examples Add warning in CLI when files config have same folder path (#324) 2022-11-16 20:18:26 -05:00
src feat: Upgrade CLI dependencies 2023-02-27 14:01:31 -05:00
CHANGELOG.md Fix document path parsing for parent directory 2019-12-12 12:36:50 -05:00
LICENSE.md Add cli in the repo to truly become a MONOREPO 🎉 2019-03-04 17:16:50 -05:00
package-lock.json feat: Upgrade CLI dependencies 2023-02-27 14:01:31 -05:00
package.json feat: Upgrade CLI dependencies 2023-02-27 14:01:31 -05:00
README.md Add missing YAML syntax highlighting 2022-11-15 15:54:13 -05:00
tsconfig.json Update NodeJS deps for webapp and cli 2022-02-28 11:41:08 -05:00

Accent CLI

Version Build Status

Usage

$ npm install -g accent-cli
$ accent COMMAND
running command...
$ accent (-v|--version|version)
accent-cli/0.12.0 darwin-x64 node-v16.15.1
$ accent --help [COMMAND]
USAGE
  $ accent COMMAND
...

Configuration

accent-cli reads from a accent.json file. The file should contain valid JSON representing the configuration of your project.

Example

{
  "apiUrl": "http://your.accent.instance",
  "apiKey": "2nziVSaa8yUJxLkwoZA",
  "files": [
    {
      "format": "json",
      "source": "localization/fr/*.json",
      "target": "localization/%slug%/%document_path%.json",
      "hooks": {
        "afterSync": "touch sync-done.txt"
      }
    }
  ]
}

Document configuration

Each operation section sync and addTranslations can contain the following object:

  • language: The identifier of the documents language
  • format: The format of the document
  • source: The path of the document. This can contain glob pattern (See [the node glob library] used as a dependancy (https://github.com/isaacs/node-glob))
  • target: Path of the target languages
  • hooks: List of hooks to be run

Hooks

Here is a list of available hooks. Those are self-explanatory

  • beforeSync
  • afterSync
  • beforeExport
  • afterExport

Commands

accent export

Export files from Accent and write them to your local filesystem

USAGE
  $ accent export

OPTIONS
  --order-by=index|key  [default: index] Will be used in the export call as the order of the keys

EXAMPLE
  $ accent export

See code: src/commands/export.ts

accent format

Format local files from server. Exit code is 1 if there are errors.

USAGE
  $ accent format

OPTIONS
  --order-by=index|key  [default: index] Order of the keys

EXAMPLE
  $ accent format

See code: src/commands/format.ts

accent help [COMMAND]

display help for accent

USAGE
  $ accent help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

accent jipt PSEUDOLANGUAGENAME

Export jipt files from Accent and write them to your local filesystem

USAGE
  $ accent jipt PSEUDOLANGUAGENAME

ARGUMENTS
  PSEUDOLANGUAGENAME  The pseudo language for in-place-translation-editing

EXAMPLE
  $ accent jipt

See code: src/commands/jipt.ts

accent lint

Lint local files and display errors if any. Exit code is 1 if there are errors.

USAGE
  $ accent lint

EXAMPLE
  $ accent lint

See code: src/commands/lint.ts

accent stats

Fetch stats from the API and display it beautifully

USAGE
  $ accent stats

EXAMPLE
  $ accent stats

See code: src/commands/stats.ts

accent sync

Sync files in Accent and write them to your local filesystem

USAGE
  $ accent sync

OPTIONS
  --add-translations                Add translations in Accent to help translators if you already have translated
                                    strings

  --dry-run                         Do not write the file from the export _after_ the operation

  --merge-type=smart|passive|force  [default: smart] Will be used in the add translations call as the "merge_type" param

  --order-by=index|key              [default: index] Will be used in the export call as the order of the keys

  --sync-type=smart|passive         [default: smart] Will be used in the sync call as the "sync_type" param

EXAMPLE
  $ accent sync

See code: src/commands/sync.ts

GitHub Actions

In addition to syncing the translations manually, you can add a GitHub Actions workflow to your project in order to automate the process.

Example

name: Accent

on:
  schedule:
    - cron: "0 4 * * *"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - run: npm install -g accent-cli
      - run: accent sync --add-translations --merge-type=passive --order-by=key
      - uses: peter-evans/create-pull-request@v4
        with:
          add-paths: "*.json"
          commit-message: Update translations
          committer: github-actions[bot]@users.noreply.github.com
          author: github-actions[bot]@users.noreply.github.com
          branch: accent
          draft: false
          delete-branch: true
          title: New translations are available to merge
          body: The translation files have been updated, feel free to merge this pull request after review.

In this example the translations will be synchronized daily at midnight eastern time. Using a pull request gives you the opportunity to review the changes before merging them in your codebase.

License

accent-cli is © 2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. Were a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.