wuchale logo


npm package build status Start new PR in StackBlitz Codeflow discord chat


# 📜`wuchale`🪶 **`wuchale`** (pronounced /wʊtʃɑleɪ/ or _wuh-'CHAH-lay_) is a compile-time internationalization toolkit that requires no code changes. Write your components naturally, and `wuchale` automatically extracts and replaces translatable messages at build time. - **No extra syntax!** - Your normal code is enough, your codebase stays clean - **Tiny catalogs to bundle** - Text catalogs are just arrays, no keys necessary, like Protobuf - **Zero-effort integration** - Add i18n to existing projects without rewriting code - **Framework agnostic** - Works with React, Preact, Svelte(Kit), SolidJS, Astro, and plain JS/TS - **Full URLs support** - E.g. `/about` to `/de/uber-uns` - **LLM translation support** - Configurable integration for automatic on-the-fly translations - **Full, granular HMR** - Live updates during development, including LLM translation - **Tiny footprint** - Very few (less than 5) additional dependencies, no bloated `node_modules` - **Smart extraction** - Uses AST analysis to handle nested markup, conditionals, loops, and complex interpolations - **Storage agnostic** - Standard PO files by default, storage interface to store translations anywhere ## A taste With traditional i18n: ```svelte

{t('Hello')}

Welcome {userName}

``` With `wuchale`: ```svelte

Hello

Welcome {userName}

``` No imports, no special components, no annotations. `wuchale` handles everything at compile time by analyzing your code and automatically extracting translatable strings. ## Getting started See the [Getting Started guide](https://wuchale.dev/intro/start/) for instructions specific to your project type. ## How it works 1. **Scans your source code** using AST and identify translatable text content 2. **Extracts strings** into standard `.po` translation files (or custom storage) for translators 3. **Compiles catalogs** into compact modules which export arrays 4. **Replaces strings** with translation function calls that access messages by indices from the arrays Your original code stays clean and readable, while the build output is automatically internationalized. ## Example Let's say you have: ```jsx // src/components/Welcome.jsx function Welcome({ user }) { return (

Hello, {user}, and welcome!

) } ``` The messages are extracted into a `.po` file. for Spanish for example, after translation, it looks like: ```po #~ src/components/Welcome.jsx msgid "<0>Hello, {0}, and welcome!" msgstr "<0>Hola, {0}, y ¡bienvenido!" #~ src/components/Welcome.jsx msgid "Get started" msgstr "Comenzar" ``` Then they are compiled into a compact form optimized for loading (just an array): ```js export let c = [[[0, "Hola, ", 0], ", y ¡bienvenido!"], "Comenzar"] ``` And your code is transformed into a version that accesses them by index: ```jsx // src/components/Welcome.jsx import W_tx_ from "@wuchale/jsx/runtime.jsx" function Welcome({ user }) { const _w_runtime_ = _w_load_rx_(); return (

]} x={_w_runtime_.c(0)} />

) } ``` Notice the automatic handling of the nested ``, that's wuchale's full supported for indefinite nesting at play. You can nest as deep as you want, and it still makes it work for i18n. That gives the translator freedom to even reorder placeholders and it gets rendered accordingly. Check out full working examples for different setups at **[`wuchalejs/examples`](https://github.com/wuchalejs/examples)** to see `wuchale` in action with different frameworks. ## Repository structure This is a monorepo that houses these packages: | Package | Description | Latest | | -------- | ------- | --- | | `wuchale` | Core + CLI + Vanilla adapter |[![wuchale](https://img.shields.io/npm/v/wuchale?logo=npm&logoColor=red&color=blue")](https://npmjs.com/package/wuchale) | | `@wuchale/jsx` | JSX adapter (for React and SolidJS) |[![@wuchale/jsx](https://img.shields.io/npm/v/@wuchale/jsx?logo=npm&logoColor=red&color=blue")](https://npmjs.com/package/@wuchale/jsx)| | `@wuchale/svelte` | Svelte adapter |[![@wuchale/svelte](https://img.shields.io/npm/v/@wuchale/svelte?logo=npm&logoColor=red&color=blue")](https://npmjs.com/package/@wuchale/svelte)| | `@wuchale/astro` | Astro adapter |[![@wuchale/astro](https://img.shields.io/npm/v/@wuchale/astro?logo=npm&logoColor=red&color=blue")](https://npmjs.com/package/@wuchale/astro)| | `@wuchale/json` | JSON storage |[![@wuchale/json](https://img.shields.io/npm/v/@wuchale/json?logo=npm&logoColor=red&color=blue")](https://npmjs.com/package/@wuchale/json)| ## Contributing Contributions are welcome! Please check out the test suites located inside each package for examples of supported scenarios. **Note**: The tests are also written in TypeScript and therefore you should have Node 22+ to run them. ## Sponsors This project is supported by the community. Become a sponsor and get your name or logo listed on the README and the website! [![Sponsor on GitHub](https://img.shields.io/badge/Sponsor%20on-GitHub-%23ea4aaa?logo=github&logoColor=white)](https://github.com/sponsors/K1DV5) Special thanks to our supporters: [![p-mercury](https://avatars.githubusercontent.com/u/9084532?v=4&s=48)](https://github.com/p-mercury) Past supporters: [![mightygroup](https://avatars.githubusercontent.com/u/24351170?v=4&s=48)](https://github.com/mightygroup) [![hayzamjs](https://avatars.githubusercontent.com/u/3922884?v=4&s=48)](https://github.com/hayzamjs) [![perdix](https://avatars.githubusercontent.com/u/1526654?v=4&s=48)](https://github.com/perdix) [![ZerGo0](https://avatars.githubusercontent.com/u/18653821?v=4&s=48)](https://github.com/ZerGo0) And one private donor 🙏. ## License [MIT](LICENSE)