Skip to content

Getting started

To install wuchale, you have to install the base package and the adapter(s) you want to use. The adapter for vanilla JS/TS projects is built into the base package. For other projects, the adapter package has to be installed additionally.

This installation guide assumes that you have your source files under src. If not, you will have to configure the adapter and provide the files.

  1. Install

    Terminal window
    npm install wuchale @wuchale/jsx @wuchale/vite-plugin
  2. Configure Vite

    vite.config.js
    import { defineConfig } from 'vite'
    import react from '@vitejs/plugin-react'
    import { wuchale } from '@wuchale/vite-plugin'
    export default defineConfig({
    plugins: [ wuchale(), react() ],
    })
  3. Create Configuration

    wuchale.config.js
    // @ts-check
    import { adapter as jsx } from "@wuchale/jsx"
    import { defineConfig } from "wuchale"
    export default defineConfig({
    // sourceLocale is en by default
    otherLocales: ['es'],
    adapters: {
    main: jsx(),
    }
    })
  4. Initialize locales

    Terminal window
    npx wuchale init

    This command:

    • Creates the locales directory if it doesn’t exist
    • Creates the loader files, asking you which is correct
    • Performs an initial extraction
  5. Setup in Your App

    Now that the loader files are created, you can edit them, export the things you need from there, and setup how the translations are loaded.

    Look in the React setup guide

  6. Start Coding!

    Write your code components naturally. wuchale will extract and compile translations automatically:

    function Hello() {
    return <p>Hello world</p>
    }

For full usage examples, look inside the examples repository. It contains examples for different frameworks and usage patterns.

wuchale’s workflow is inspired by Lingui. It follows similar steps but it does most of the steps automatically.

  1. You write your code

  2. wuchale auto extracts the messages into the catalog files

    During this step, if configured, Gemini does the automatic translation

  3. The translator translates the messages by editing the extracted .po files

  4. wuchale picks up the changes and updates the UI during dev

  5. When you do the production build, wuchale auto compiles the catalogs and passes them to Vite to be included in the final build.