Lara CLI: Setup & Intallation
CLI Installation
- Prerequisites
Before installing, ensure you have the following requirements met:
- Node.js: version 16.0.0 or higher.
- npm: usually bundled with Node.js.
NoteThis project uses pnpm. If you don't have it installed, run:
npm install -g pnpm. Verify the installation withpnpm -vbefore proceeding with the following commands.
- Global Installation
For most use cases, we recommend installing the CLI globally. This allows you to use the lara command from any directory on your system.
pnpm install -g @translated/lara-cli- Local Installation
If you prefer to keep dependencies project-specific, you can install it as a development dependency:
pnpm install --save-dev @translated/lara-cliWhen installed locally, you can trigger the CLI using npx:
npx lara --versionLocal Development Setup
- Clone the repository
git clone https://github.com/translated/lara-cli.git- Navigate to the cloned repository
cd lara-cli- Install dependencies and build
Note: This project uses pnpm. If you don't have it installed, run:
npm install -g pnpm. Verify the installation withpnpm -vbefore proceeding with the following commands.
pnpm install
pnpm run build- Setup pnpm global bin directory (first time only)
pnpm setupThis command configures your shell to add the pnpm global bin directory to your PATH. After running it, you'll see output similar to:
Appended new lines to /Users/<username>/.zshrc
Next configuration changes were made:
export PNPM_HOME="/Users/<username>/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esacAdd these lines to your shell profile (.zshrc, .bashrc, etc.) or restart your terminal to apply the changes. This ensures you can run globally installed pnpm packages.
- Link globally
pnpm link --globalNote: If you experience an error like
ERR_PNPM_NO_GLOBAL_BIN_DIR, you may need to manually copy and paste the lines added bypnpm setupinto your shell profile. After doing so, restart your terminal or source your profile file, and you should be able to proceed.
After running this command, the project will be successfully linked to the pnpm global library. You should see a response similar to:
/Users/username/Library/pnpm/global/5:
+ lara-cli version <- ../../../../Projects/translated/lara-cli- Installation Complete - Use anywhere
Now that Lara Dev is installed globally, you can use it from any directory on your system:
# Get help with available commands
lara-cli --help
# Initialize a new Lara project
lara-cli init --help
# Translate your localization files
lara-cli translate --helpNote: After making changes to the source code, run pnpm run build to update the global command.
Setting Up Your Project
Add Your Credentials to .env
.envCreate a .env file (or add the following lines to an existing .env) in the project where you want to run translations.
💡 Tip: If you don't have API keys yet, visit Lara's API key documentation.
LARA_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
LARA_ACCESS_KEY_SECRET=<YOUR_ACCESS_KEY_SECRET>Replace the placeholders with your actual credentials.
🔑 Need to update credentials? If your API keys expire or need updating, run
lara-cli init --reset-credentialsto safely update them in your.envfile.
Initialize Your Project
In your project directory, run:
lara-cli initThis will start the interactive initialization process.
The CLI will automatically detect your localization directories and target locales from your existing project files, then guide you through a few questions. These will be used to generate the configuration file: lara.yaml.
Updated 1 day ago
