Localazy CLI Tips: Using absolute paths

Another Localazy CLI Tip for you! Some of you have been asking us to add support for absolute paths into the CLI. We have some good news: it’s already available 😉 Let me show you two ways how you can use them.

Localazy CLI is our command-line interface, and you can use it to upload files to the Localazy platform and download translations back to your app. You can easily integrate it into your build chain or CI/CD.

Learn how to get started with Localazy CLI in our documentation.

❓ Why absolute paths?

To be honest, I'm not a fan of absolute paths, mainly because they tightly couple the code/configuration with a particular environment. However, there are also several use cases pointed out by our users where using absolute paths may be beneficial.

One of them is a centralized localization for several different projects or collecting/outputting localizable files across several folders on the file system.

We've improved support for absolute path in Localazy CLI 1.2.21, so be sure to keep your tools updated 😉.

Absolute base folder

This one is my favorite. Basically, you can tell Localazy CLI in which folder you want to perform upload and download actions using upload.folder or download.folder.

Here's an example for Windows, but it's going to work the same way on Linux as well as macOS:

{
    "upload": {
        "folder": "C:\\Users\\Localazy\\projects",
        "files": "assets\\i18n\\en.json"
  },
    "download": {
        "folder": "C:\\Users\\Localazy\\projects\\build",
        "files": "assets\\i18n\\${lang}.json"
  }  
}

Note: Backslashes in the JSON string must be escaped, and thus all those \\ in the path.

Separated absolute paths

This one is useful if you need to collect files from different folders across your file system.

{
    "upload": {
        "folder": "",
        "files": "C:\\Users\\Localazy\\projects\\assets\\i18n\\en.json"
  },
    "download": {
        "folder": "",
        "files": "C:\\Users\\Localazy\\projects\\build\\assets\\i18n\\${lang}.json"
  }  
}

Note: By default, the folder is set to . to allow relative paths. If you want to use absolute paths in patterns, you need to set it to an empty string.

Tip: You can read more #DevTips on our blog!

CLI friendly app localization

Make sure you do not miss this update. Whether it is iOS or TypeScript app, you can localize your app using brand new Localazy CLI.

Read more