Skip to content

Set up the i18n with automated translation #96

@vitonsky

Description

@vitonsky

Motivation

Localization is important for SEO and can significantly expand the audience a product can reach.

Localization automation makes the process almost trivial — developers only need to run npx transly translate and publish a new version of the site. After that, the site becomes available in all target languages.

The proposal

Let's introduce i18n via i18next, and automate translation process via transly. Transly uses LLMs, or any machine translation including free fallback to Google Translation services that require no API keys and allow us to implement a free zero config translation out of the box.

Example transly.config.ts:

import 'dotenv/config';
import { defineConfig } from 'transly';

export default defineConfig({
  sourceLang: 'en',
  targetLangs: ['es', 'zh', 'ru', 'pt-BR'],
  localesDir: './src/locales',

  llm: {
    model: 'google/gemma-4-26b-a4b-it',
    apiKey: process.env.OPENAI_API_KEY,
    baseUrl: 'https://openrouter.ai/api/v1',
  },
});

Then user will run npx transly translate to translate only changed keys from source locale into all others.

Transly support a fallback to a free Google Translation service if llm config is not provided, so even those developers who do not have API tokens can automate the translation.

I’ve already translated a few apps this way, and the translation quality has been quite good. You can check the translation examples. And our production config as example with providing the app context, to ensure consistent terms use.

Transly implements incremental translation for only those keys that have been changed, so no hassle with translate whole namespace file in all languages just because you've updated some text in one button.

I can send PR if you're opened for that feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions