Skip to content

Commit cee4edf

Browse files
committed
chore: initial public release
0 parents  commit cee4edf

82 files changed

Lines changed: 21401 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22.20.0'
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 10.11.1
29+
30+
- name: Get pnpm store directory
31+
shell: bash
32+
run: |
33+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
34+
35+
- name: Setup pnpm cache
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ env.STORE_PATH }}
39+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pnpm-store-
42+
43+
- name: Install dependencies
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: Run tests
47+
run: pnpm run test
48+
49+
- name: Build project
50+
run: pnpm run build
51+
52+
- name: Validate version matches tag
53+
run: |
54+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
55+
TAG_VERSION=${GITHUB_REF_NAME#v}
56+
57+
echo "Package version: $PACKAGE_VERSION"
58+
echo "Tag version: $TAG_VERSION"
59+
60+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
61+
echo "Error: package.json version ($PACKAGE_VERSION) does not match git tag version ($TAG_VERSION)."
62+
exit 1
63+
fi
64+
65+
- name: Publish to npm
66+
run: pnpm publish --access public --no-git-checks
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69+

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Environment variables
2+
.env
3+
4+
# Build
5+
build/
6+
7+
# Node modules
8+
node_modules/
9+
10+
# OS files
11+
.DS_Store
12+
13+
# Lara
14+
lara.yaml
15+
.lara/
16+
17+
# Test files
18+
i18n-test/
19+
20+
# VSCode files
21+
.vscode/
22+
23+
# Coverage files
24+
coverage/
25+
26+
# tmp files
27+
tmp/

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build
3+
dist
4+
*.map
5+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf",
10+
"bracketSpacing": true
11+
}

README.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
<div align="center">
2+
3+
# 🚀 Lara Cli – A Powerful CLI Tool for Instant i18n Localization
4+
5+
Lara Cli automates translation of your i18n files with a single command, preserving structure and formatting while integrating with a professional translation API. Given a source language, it translates your content to selected target languages based on your source i18n files.
6+
7+
Supports multiple file formats including JSON, PO (gettext), TypeScript, Vue I18n single-file components, Markdown and MDX files, and Android XML string resource files. See [Supported Formats](docs/config/formats.md) for details.
8+
9+
[![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/translated/lara-cli)
10+
11+
</div>
12+
13+
## 📑 Table of Contents
14+
15+
- [Installation](#installation)
16+
- [Setting Up Your Project](#setting-up-your-project)
17+
- [Local Development Setup](#local-development-setup)
18+
- [Technology Stack](#technology-stack)
19+
- [Supported Locales](#supported-locales)
20+
- [Documentation](#documentation)
21+
22+
## Installation
23+
24+
### Requirements
25+
26+
- Node.js v18 or higher
27+
28+
### Install via npm
29+
30+
The easiest way to get started is to install Lara CLI globally via npm:
31+
32+
```bash
33+
npm install -g @translated/lara-cli
34+
```
35+
36+
Once installed, you can use it from any directory:
37+
38+
```bash
39+
# Get help with available commands
40+
lara-cli --help
41+
42+
# Initialize a new Lara project
43+
lara-cli init --help
44+
45+
# Translate your localization files
46+
lara-cli translate --help
47+
```
48+
49+
## Setting Up Your Project
50+
51+
### Add Your Credentials to `.env`
52+
53+
Create a `.env` file (or add the following lines to an existing `.env`) in the project where you want to run translations.
54+
55+
💡 **Tip:** If you don't have API keys yet, visit [Lara's API key documentation](https://support.laratranslate.com/en/api-key-for-laras-api).
56+
57+
```bash
58+
LARA_ACCESS_KEY_ID=<YOUR_ACCESS_KEY_ID>
59+
LARA_ACCESS_KEY_SECRET=<YOUR_ACCESS_KEY_SECRET>
60+
```
61+
62+
Replace the placeholders with your **actual credentials**.
63+
64+
> **🔑 Need to update credentials?** If your API keys expire or need updating, run `lara-cli init --reset-credentials` to safely update them in your `.env` file.
65+
66+
### Initialize Your Project
67+
68+
In your project directory, run:
69+
70+
```bash
71+
lara-cli init
72+
```
73+
74+
This will start the interactive initialization process.
75+
76+
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`.
77+
78+
**Key features:**
79+
80+
- 🔍 **Auto-detection**: Scans your project for existing locale files and automatically suggests target locales
81+
- 📊 **Smart display**: For enterprise projects with many locales, uses formatted tables for better readability
82+
- ⚙️ **Flexible configuration**: Choose detected locales or manually add/remove as needed
83+
- 🎯 **Project instructions**: Optionally provide instructions to improve translation quality (e.g., tone, style, terminology)
84+
85+
**Providing project instructions** (optional but recommended):
86+
87+
During initialization, you can provide instructions to help improve translation quality. Instructions guide the translation service on tone, style, and terminology. This is especially useful for:
88+
89+
- Tone requirements (formal, casual, professional, friendly)
90+
- Domain-specific terminology (medical, legal, technical, etc.)
91+
- Style preferences (concise, creative, detailed)
92+
93+
**Providing glossaries** (optional but recommended):
94+
95+
Lara's glossary system lets you define exactly how specific terms should be translated, across any text or document. Whether you work with technical terms, product names, or recurring brand phrases, glossaries are your best tool to ensure consistency and precision.
96+
97+
💡 **Tip:** For more information about glossaries, visit [Lara's Glossary documentation](https://support.laratranslate.com/en/how-glossaries-work-in-lara).
98+
99+
### Translate Your Files
100+
101+
To translate your files into the target locales, run:
102+
103+
```bash
104+
lara-cli translate
105+
```
106+
107+
That's it – you're ready to go!
108+
109+
> **📖 Documentation:** For detailed information about commands, see [Init Command](docs/commands/init.md) and [Translate Command](docs/commands/translate.md).
110+
111+
## Local Development Setup
112+
113+
If you want to contribute to Lara CLI or run it from source, follow these steps.
114+
115+
### Requirements
116+
117+
- Node.js v18 or higher
118+
- pnpm v8 or higher
119+
120+
1. **Clone the repository**
121+
122+
```bash
123+
git clone https://github.com/translated/lara-cli.git
124+
```
125+
126+
2. **Navigate to the cloned repository**
127+
128+
```bash
129+
cd lara-cli
130+
```
131+
132+
3. **Install dependencies and build**
133+
134+
> **Note:** This project uses pnpm. If you don't have it installed, run: `npm install -g pnpm`. Verify the installation with `pnpm -v` before proceeding with the following commands.
135+
136+
```bash
137+
pnpm install
138+
pnpm run build
139+
```
140+
141+
4. **Setup pnpm global bin directory (first time only)**
142+
143+
```bash
144+
pnpm setup
145+
```
146+
147+
This command configures your shell to add the pnpm global bin directory to your PATH. After running it, you'll see output similar to:
148+
149+
```bash
150+
Appended new lines to /Users/<username>/.zshrc
151+
152+
Next configuration changes were made:
153+
export PNPM_HOME="/Users/<username>/Library/pnpm"
154+
case ":$PATH:" in
155+
*":$PNPM_HOME:"*) ;;
156+
*) export PATH="$PNPM_HOME:$PATH" ;;
157+
esac
158+
```
159+
160+
Add 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.
161+
162+
5. **Link globally**
163+
164+
```bash
165+
pnpm link --global
166+
```
167+
168+
> **Note:** If you experience an error like `ERR_PNPM_NO_GLOBAL_BIN_DIR`, you may need to manually copy and paste the lines added by `pnpm setup` into your shell profile. After doing so, restart your terminal or source your profile file, and you should be able to proceed.
169+
170+
After running this command, the project will be successfully linked to the pnpm global library. You should see a response similar to:
171+
172+
```bash
173+
/Users/username/Library/pnpm/global/5:
174+
+ lara-cli version <- ../../../../Projects/translated/lara-cli
175+
```
176+
177+
6. **Development Complete - Use anywhere**
178+
179+
Now that Lara CLI is linked globally, you can use it from any directory on your system:
180+
181+
```bash
182+
# Get help with available commands
183+
lara-cli --help
184+
185+
# Initialize a new Lara project
186+
lara-cli init --help
187+
188+
# Translate your localization files
189+
lara-cli translate --help
190+
```
191+
192+
**Note:** After making changes to the source code, run `pnpm run build` to update the global command.
193+
194+
## Technology Stack
195+
196+
Lara CLI is built with modern technologies to ensure reliability, performance, and maintainability:
197+
198+
- **TypeScript** - For type safety and developer experience
199+
- **Commander.js** - For CLI argument parsing and command structure
200+
- **Zod** - For robust schema validation
201+
- **Inquirer.js** - For interactive command-line user interfaces
202+
- **Lara Translation API** - For high-quality, context-aware translations
203+
204+
The codebase follows a modular architecture with clear separation of concerns, making it easy to extend and maintain.
205+
206+
## Supported Locales
207+
208+
Lara CLI supports translations using different locale codes, following two main standards:
209+
210+
See the [full list of supported locales](docs/config/locales.md#supported-locales).
211+
212+
## Documentation
213+
214+
For detailed documentation on using Lara CLI:
215+
216+
### Commands
217+
218+
- [Init Command](docs/commands/init.md) - Initialize your project
219+
- [Translate Command](docs/commands/translate.md) - Translate your files
220+
- [Memory Command](docs/commands/memory.md) - List available Translation Memories
221+
- [Glossary Command](docs/commands/glossary.md) - List available Glossaries
222+
223+
### Configuration
224+
225+
- [Configuration Overview](docs/config/README.md) - Configuration system overview
226+
- [Supported Formats](docs/config/formats.md) - Supported file formats (JSON, PO, etc.)
227+
- [Locales Configuration](docs/config/locales.md) - Configure source and target languages
228+
- [Files Configuration](docs/config/files.md) - Configure file paths and patterns
229+
- [Instructions](docs/config/instructions.md) - Configure translation instructions
230+
- [Translation Memories](docs/config/memories.md) - Configure Translation Memories
231+
- [Glossaries](docs/config/glossaries.md) - Configure Glossaries
232+
233+
### Format-Specific Guides
234+
235+
- [TS Files Guide](docs/config/files/ts-files.md) - Complete guide for TypeScript files
236+
- [PO Files Guide](docs/config/files/po-files.md) - Complete guide for gettext PO files
237+
- [Vue Files Guide](docs/config/files/vue-files.md) - Complete guide for Vue I18n single-file components
238+
- [Markdown Files Guide](docs/config/files/md-files.md) - Complete guide for Markdown and MDX files
239+
- [Android XML Files Guide](docs/config/files/android-xml-files.md) - Complete guide for Android XML string resource files

0 commit comments

Comments
 (0)