experimental-ciao-babel
v1.1.17
Published
Babel plugin for ciao-tools - extracts translatable strings at build time
Maintainers
Readme
@ciao-tools/babel
Babel plugin for Ciao Tools - extracts translatable strings at build time.
Installation
npm install -D @ciao-tools/babelUsage
Add to your Babel config:
// babel.config.js
module.exports = {
plugins: ["@ciao-tools/babel"],
};Or with Vite:
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [
react({
babel: {
plugins: ["@ciao-tools/babel"],
},
}),
],
});What it extracts
The plugin scans your code for:
ct()function calls with string literals<CTContextBlock id="...">components for context grouping
// These strings are extracted:
ct("Hello, world!");
ct("Welcome back, {name}", { name: userName });
<CTContextBlock id="checkout-page">
<p>{ct("Review your order")}</p>
<p>{ct("Proceed to payment")}</p>
</CTContextBlock>Exports
default- Babel plugin functionbuildSchema()- Generate schema from extraction resultcreateExtractionPlugin()- Create plugin with custom options
Documentation
See docs.ciao-tools.com/babel for full documentation.
License
MIT
