Getting started
Installation
Section titled “Installation”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.
-
Install
Terminal window npm install wuchale @wuchale/jsx -
Configure Vite
vite.config.js import { defineConfig } from 'vite'import react from '@vitejs/plugin-react'import { wuchale } from 'wuchale/vite'export default defineConfig({plugins: [ wuchale(), react() ],}) -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as jsx } from "@wuchale/jsx"import { defineConfig } from "wuchale"export default defineConfig({locales: ['en', 'es'],adapters: {main: jsx({ loader: 'react' }),}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App
Connect the locale selection and loading logic to your app. Follow the React setup guide.
-
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:function Hello() {return <p>Hello world</p>}
-
Install
Terminal window npm install wuchale @wuchale/svelte -
Configure Vite
vite.config.js import { svelte } from '@sveltejs/vite-plugin-svelte'import { wuchale } from 'wuchale/vite'export default {plugins: [ wuchale(), svelte() ]} -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as svelte } from "@wuchale/svelte"import { defineConfig } from "wuchale"export default defineConfig({locales: ['en', 'es'],adapters: {main: svelte({ loader: 'svelte' }),}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App
Connect the locale selection and loading logic to your app. Follow the Svelte setup guide.
-
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:<p>Hello world</p>
-
Install
Terminal window npm install wuchale @wuchale/svelte -
Configure Vite
vite.config.js import { sveltekit } from '@sveltejs/kit/vite'import { wuchale } from 'wuchale/vite'export default {plugins: [ wuchale(), sveltekit() ]} -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as svelte } from "@wuchale/svelte"import { adapter as js } from 'wuchale/adapter-vanilla'import { defineConfig } from "wuchale"export default defineConfig({locales: ['en', 'es'],adapters: {main: svelte({ loader: 'sveltekit' }),js: js({loader: 'vite',files: ['src/**/+{page,layout}.{js,ts}','src/**/+{page,layout}.server.{js,ts}',],})}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App
Connect the locale selection and loading logic to your app. Follow the SvelteKit setup guide.
-
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:<p>Hello world</p>
-
Install
Terminal window npm install wuchale @wuchale/jsx -
Configure Vite
vite.config.js import { defineConfig } from 'vite';import solidPlugin from 'vite-plugin-solid';import { wuchale } from 'wuchale/vite';export default defineConfig({plugins: [wuchale(), solidPlugin()],}); -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as jsx } from "@wuchale/jsx"import { defineConfig } from "wuchale"export default defineConfig({locales: ['en', 'es'],adapters: {main: jsx({loader: 'solidjs',variant: 'solidjs',}),}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App
Connect the locale selection and loading logic to your app. Follow the SolidJS setup guide.
-
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:function Hello() {return <p>Hello world</p>}
-
Install
Terminal window npm install wuchale @wuchale/astro -
Configure Vite
astro.config.js import { wuchale } from 'wuchale/vite';import { defineConfig } from 'astro/config';// https://astro.build/configexport default defineConfig({vite: {plugins: [wuchale()],},i18n: {locales: ['en', 'es'],defaultLocale: 'en',routing: {prefixDefaultLocale: true,}},}); -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as astro } from "@wuchale/astro"import { defineConfig } from "wuchale"export default defineConfig({locales: ['en', 'es'],adapters: {main: astro(),}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App
Connect the locale selection and loading logic to your app. Follow the Astro setup guide.
-
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:<p>Hello world</p>
-
Install
Terminal window npm install wuchale -
Configure Vite (only if using Vite)
vite.config.js import { wuchale } from 'wuchale/vite'export default {plugins: [wuchale()]} -
Create Configuration
wuchale.config.js // @ts-checkimport { adapter as basic } from 'wuchale/adapter-vanilla'import { defineConfig } from 'wuchale'export default defineConfig({locales: ['en', 'es'],adapters: {main: basic({loader: 'vite' // If using Vite. Otherwise 'default'})}}) -
Scaffold and initial extract
Terminal window npx wuchale -
Setup in Your App (if using Vite)
Connect the locale selection and loading logic to your app.
import { loadLocale } from 'wuchale/load-utils'await loadLocale(locale) -
Start Coding!
Write your code components naturally.
wuchalewill extract and compile translations automatically:E.g. DOM
const showMsg = (element) => {element.innerHTML = 'Hello world'}
For full usage examples, look inside the examples repository. It contains examples for different frameworks and usage patterns.
Workflow
Section titled “Workflow”wuchale’s workflow is inspired by Lingui. It follows
similar steps but it does most of the steps automatically.
-
You write your code
-
wuchaleauto extracts the messages into the catalog filesDuring this step, if configured, AI does the automatic translation
-
The translator translates the messages by editing the extracted
.pofiles -
wuchalepicks up the changes and updates the UI during dev -
When you do the production build,
wuchaleauto compiles the catalogs and passes them to Vite to be included in the final build.
-
You write your code
-
You invoke the CLI command
wuchaleto extract the messages into the catalog filesDuring this step, if configured, AI does the automatic translation
-
The translator translates the messages by editing the extracted
.pofiles -
You invoke the CLI command
wuchaleagain to compile the translated messages and write them to disk -
When you run the app, everything works.