lokit

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 21 Imported by: 0

README ΒΆ

lokit β€” Localization Kit

lokit is a universal localization manager with AI-powered translation. It supports gettext PO, po4a documentation, i18next JSON, and simple JSON formats β€” either auto-detected or configured via .lokit.yaml.

Features

  • πŸ”§ Multi-target config β€” .lokit.yaml for complex projects with multiple translation types
  • πŸš€ Auto-detection β€” works without config for simple projects (flat PO, nested PO, po4a, i18next)
  • πŸ€– AI translation β€” 7 providers including free GitHub Copilot and Gemini
  • πŸ“Š Translation statistics β€” per-target progress tracking
  • πŸ”„ Smart PO management β€” extract, merge, update with xgettext and msgmerge
  • πŸ” Native OAuth β€” GitHub Copilot (device code) and Gemini (browser)
  • ⚑ Parallel translation β€” concurrent API requests with configurable chunking

Supported Formats

Format Extension Use case
gettext .po / .pot Source code strings (shell, Python, C)
po4a .po + po4a.cfg Documentation / manpages
i18next .json (_meta) Web apps with i18next
json .json (translations) Simple JSON key-value translations

Supported AI Providers

Provider Auth Free tier
GitHub Copilot OAuth (device code) βœ… with GitHub account
Gemini Code Assist OAuth (browser) βœ… 60 req/min
Google AI (Gemini) API key βœ… limited
Groq API key βœ… limited
OpenCode API key β€”
Ollama none (local) βœ…
Custom OpenAI API key depends

Installation

From source
git clone https://github.com/minios-linux/lokit.git
cd lokit
make build
Using go install
go install github.com/minios-linux/lokit@latest
Check version
lokit version

Quick Start

Simple project (auto-detection)
# Check project structure
lokit status

# Extract strings and create PO files
lokit init

# Authenticate
lokit auth login --provider copilot

# Translate all languages
lokit translate --provider copilot --model gpt-4.1
Complex project (.lokit.yaml)

Create a .lokit.yaml in the project root:

languages: [de, es, fr, ru]
source_lang: en

targets:
  - name: app
    type: gettext
    po_dir: po

  - name: docs
    type: po4a
    root: manpages
    po4a_config: po4a.cfg

  - name: website
    type: i18next
    root: submodules/site
    translations_dir: public/translations
    languages: [de, es, fr, pt-BR, ru]

Then:

lokit status        # Shows all targets with stats
lokit translate --provider copilot --model gpt-4o  # Translates everything

Configuration File (.lokit.yaml)

When .lokit.yaml exists, lokit uses it as the sole source of truth β€” no auto-detection.

Schema
# Default languages for all targets
languages: [de, es, fr, id, it, pt, pt_BR, ru]

# Source language (default: en)
source_lang: en

# Translation targets
targets:
  - name: my-app              # Display name (required)
    type: gettext              # Type: gettext | po4a | i18next | json (required)
    root: .                    # Working directory relative to config (default: .)

    # --- gettext options ---
    po_dir: po                 # PO directory relative to root (default: po)
    pot_file: po/messages.pot  # POT template path (default: po/messages.pot)
    sources: [src/**/*.sh]     # Source globs for xgettext
    keywords: [_, N_, gettext] # xgettext keywords

    # --- po4a options ---
    po4a_config: po4a.cfg      # po4a config path relative to root

    # --- i18next / json options ---
    translations_dir: public/translations  # JSON directory (default: public/translations)
    recipes_dir: data/recipes              # Per-recipe translations (i18next)
    blog_dir: data/blog                    # Blog post translations (i18next)

    # --- overrides ---
    languages: [de, es, fr]    # Override global language list
    source_lang: en            # Override source language
    prompt: "Custom prompt"    # Override system prompt for AI
Target types

gettext β€” For code translation (shell, Python, C). Reads .pot templates, translates to .po files.

po4a β€” For documentation (manpages, Markdown). Works with po4a.cfg and its PO directory.

i18next β€” For web applications using i18next. JSON files with _meta block.

json β€” For simple JSON translations. JSON files with translations block.

Commands

lokit status

Shows project info and translation statistics. With .lokit.yaml, displays per-target stats.

lokit status                    # Current directory
lokit status --root ./my-project  # Specific project
lokit init

Extracts translatable strings and creates/updates PO files:

lokit init                     # All languages
lokit init --lang ru,de        # Specific languages
  • Runs xgettext for code projects
  • Runs po4a --no-translations for po4a projects
  • Creates PO from POT template using msginit/msgmerge
  • Idempotent β€” safe to run repeatedly
lokit translate

Translates using AI:

lokit translate --provider copilot --model gpt-4o

# All flags:
  --provider string         AI provider (required)
  --model string            Model name (required)
  --lang string             Languages (comma-separated, default: all untranslated)
  --parallel                Enable parallel translation
  --max-concurrent int      Max concurrent tasks (default: 3)
  --chunk-size int          Entries per API request (0 = all at once)
  --retranslate             Re-translate already translated entries
  --fuzzy                   Translate fuzzy entries (default: true)
  --dry-run                 Show what would be translated
  --prompt string           Custom system prompt ({{targetLang}} placeholder)
  --proxy string            HTTP/HTTPS proxy URL
  --api-key string          API key (or LOKIT_API_KEY env)
  --base-url string         Custom API endpoint
  --timeout duration        Request timeout (0 = provider default)
  --max-retries int         Retries on rate limit (default: 3)
  --request-delay duration  Delay between parallel tasks
  --verbose                 Detailed logging
lokit auth

Manage provider credentials:

# Interactive login
lokit auth login

# Specific provider
lokit auth login --provider copilot
lokit auth login --provider google

# List stored credentials
lokit auth list

# Remove credentials
lokit auth logout --provider copilot
lokit auth logout                      # Remove all
lokit version

Show version, commit hash, and build date.

Examples

Translate a monorepo with submodules
# .lokit.yaml
languages: [de, es, fr, id, it, pt, pt_BR, ru]
targets:
  - name: scripts
    type: gettext
    po_dir: po

  - name: manpages
    type: po4a
    root: manpages
    po4a_config: po4a.cfg

  - name: cli-tool
    type: gettext
    root: submodules/my-tool
    po_dir: po
lokit translate --provider copilot --model gpt-4o --parallel --max-concurrent 10
Parallel translation with proxy
lokit translate \
  --provider copilot --model gpt-4.1 \
  --parallel --max-concurrent 10 --chunk-size 50 \
  --proxy "http://proxy:8080"
Translate specific languages
lokit translate --provider copilot --model gpt-4o --lang ru,de
Use local Ollama
lokit translate --provider ollama --model llama3
Custom OpenAI endpoint
lokit auth login --provider custom-openai --api-key YOUR_KEY --base-url https://api.example.com/v1
lokit translate --provider custom-openai --model my-model
Dry run
lokit translate --provider copilot --model gpt-4o --dry-run

Credential Storage

Credentials are stored in:

~/.local/share/lokit/auth.json

Respects $XDG_DATA_HOME. File permissions: 0600.

Lookup order (highest β†’ lowest):

  1. --api-key flag
  2. LOKIT_API_KEY environment variable
  3. Stored credentials in auth.json

Project Structure Support

Without .lokit.yaml, lokit auto-detects:

Flat PO β€” po/*.po (shell/Python gettext)

Nested PO β€” po/<lang>/*.po (C/large projects)

po4a β€” po4a.cfg + po/<lang>/*.po (documentation)

i18next β€” translations/<lang>.json or public/translations/<lang>.json

GitHub Actions & Releases

CI/CD Workflows
  • CI β€” Tests, builds, and lints on every push/PR
  • Release β€” Builds multi-platform binaries on version tags
Creating a Release
git tag v0.2.0
git push origin v0.2.0

Automated build for Linux, macOS, and Windows with binary uploads.

View releases: https://github.com/minios-linux/lokit/releases

Development

Built with Go 1.23+:

  • cobra β€” CLI framework
  • yaml.v3 β€” YAML config parsing
  • Native OAuth for GitHub Copilot and Gemini

License

MIT License β€” see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

MiniOS Linux Team

Documentation ΒΆ

Overview ΒΆ

lokit β€” Localization Kit: gettext PO file manager with AI translation support.

Directories ΒΆ

Path Synopsis
Package config implements auto-detection of project settings from debian/changelog, existing po/ directory, etc.
Package config implements auto-detection of project settings from debian/changelog, existing po/ directory, etc.
Package copilot implements native GitHub Copilot OAuth authentication using the device code flow, without requiring any external CLI tools.
Package copilot implements native GitHub Copilot OAuth authentication using the device code flow, without requiring any external CLI tools.
Package credentials provides a unified credential store for all lokit providers, matching OpenCode's auth.json format.
Package credentials provides a unified credential store for all lokit providers, matching OpenCode's auth.json format.
Package extract wraps the GNU xgettext utility for extracting translatable strings from source files.
Package extract wraps the GNU xgettext utility for extracting translatable strings from source files.
Package gemini implements native Google OAuth2 authentication for the Gemini Code Assist API, without requiring any external CLI tools.
Package gemini implements native Google OAuth2 authentication for the Gemini Code Assist API, without requiring any external CLI tools.
Package i18next implements reading and writing of i18next JSON translation files.
Package i18next implements reading and writing of i18next JSON translation files.
Package merge implements PO file merging logic, equivalent to the msgmerge utility.
Package merge implements PO file merging logic, equivalent to the msgmerge utility.
Package po implements reading and writing of PO/POT files following the GNU gettext format specification.
Package po implements reading and writing of PO/POT files following the GNU gettext format specification.
Package translate implements AI-powered translation of PO file entries using multiple HTTP API-based AI providers: Google AI (Gemini), Groq, OpenCode (multi-format), GitHub Copilot (native OAuth), Custom OpenAI, and Ollama.
Package translate implements AI-powered translation of PO file entries using multiple HTTP API-based AI providers: Google AI (Gemini), Groq, OpenCode (multi-format), GitHub Copilot (native OAuth), Custom OpenAI, and Ollama.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL