Skip to content

v2.0.0

Compare
Choose a tag to compare
@robrechtme robrechtme released this 25 Aug 20:26
· 35 commits to main since this release

What's Changed

BREAKING: Full diff

In v1.5.1, loco-cli push would only add translations where the asset ID in the default language was not present remote. This is completely reworked. In v2, loco-cli push (and status) will look at all locales and all differences between the local files and the remote version. Depending on the new push options, this will only add new translations, also modify existing translations or even delete translations from Loco that are not present in the local file.

Pull and push options

Get access to (almost) all Loco API options for pulling translations! Options are defined as an object in .locorc under push and pull. The possible options for pull are:

  • filter: Filter assets by comma-separated tag names. Match any tag with * and negate tags by prefixing with !.
  • fallback: Fallback locale for untranslated assets, specified as short code. e.g. en or en_GB.
  • order: Export translations according to asset order.
  • status: Export translations with a specific status or flag. Negate values by prefixing with !. e.g. "translated", or "!fuzzy".
  • charset: Specify preferred character encoding. Alternative to Accept-Charset header but accepts a single value which must be valid.
  • breaks: Force platform-specific line-endings. Default is Unix (LF) breaks.

The possible options for push are:

  • ignore-new: Specify that new assets will NOT be added to the project.
  • ignore-existing: Specify that existing assets encountered in the file will NOT be updated.
  • tag-new: Tag any NEW assets added during the import with the given tags (comma separated).
  • tag-all: Tag ALL assets in the file with the given tags (comma separated).
  • untag-all: Remove existing tags from any assets matched in the imported file (comma separated).
  • tag-updated: Tag existing assets that are MODIFIED by this import.
  • untag-updated: Remove existing tags from assets that are MODIFIED during import.
  • tag-absent: Tag existing assets in the project that are NOT found in the imported file.
  • untag-absent: Remove existing tags from assets NOT found in the imported file.
  • delete-absent: Permanently DELETES project assets NOT found in the file (use with extreme caution).
  • flag-new: Set this flag on any NEW (non-empty) translations imported into the current locale.

Config types

Get enhanced IDE support by adding the type annotation above your config definition:

+ /** @type {import('loco-cli/types').Config} */
module.exports = {
  accessKey: "<loco-full-access-key>",
  localesDir: "src/app/i18n/locales",

Migration guide

defaultLanguage

The defaultLanguage option is deprecated, since loco-cli push and loco-cli status will look at all locales now. For loco-cli pull there used to be a fallback to the default language for untranslated assets. This is also removed in favor of the new pull options. It can be added back though:

-  defaultLanguage: 'en',
+ pull: {
+  fallback: 'en',
+ },

status and tag

The --status [status] and --tag [tag] options from loco-cli push are removed in favor of push options. An example migration:

// package-json
-  "translations:push": "loco-cli push --status provisional --tag $npm_package_version",
+  "translations:push": "loco-cli push",

// .locorc.js
+  push: {
+   "flag-new": "provisional",
+   "tag-new": process.env.npm_package_version,
+  },

New Contributors

Full Changelog: v1.5.1...v2.0.0