@scopeact/autoi18n 1.2.0 โ†’ 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +117 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+
2
+ # @scopeact/autoi18n
3
+
4
+ [![npm version](https://img.shields.io/npm/v/@scopeact/autoi18n.svg?style=flat-square)](https://www.npmjs.com/package/@scopeact/autoi18n)
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/felipevetter/auto-i18n/publish.yml?style=flat-square)](https://github.com/felipevetter/auto-i18n/actions)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-emerald.svg?style=flat-square)](https://opensource.org/licenses/MIT)
7
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat-square)](https://github.com/felipevetter/auto-i18n/pulls)
8
+
9
+ > The only i18n tool that handles both **Extraction** (via AST + AI) and **Runtime** (Zero-Config).
10
+
11
+ **autoi18n** is a dual-purpose tool designed to take a hardcoded React/Next.js project to full internationalization in minutes, not hours.
12
+
13
+ ---
14
+
15
+ ## โšก The Core: CLI Migration
16
+
17
+ The CLI scans your `TSX` files, extracts hardcoded strings using **Abstract Syntax Tree (AST)**, and uses **AI to generate semantic keys**.
18
+
19
+ - **No Regex:** Safe code transformations that won't break your syntax.
20
+ - **AI-Powered:** Keys like `welcome_title` instead of `text_1`.
21
+ - **Auto-Inject:** Automatically adds imports to your files.
22
+
23
+ ### Quick Start
24
+ ```bash
25
+ npx @scopeact/autoi18n init
26
+ npx @scopeact/autoi18n run
27
+ ```
28
+
29
+ ---
30
+
31
+ ## ๐Ÿš€ The Feature: Zero-Config Runtime
32
+
33
+ We noticed that even after extracting strings, configuring i18n in **Next.js (App Router)** is a nightmare (Middleware, `[locale]` folders, etc).
34
+
35
+ So we built a **minimalist, high-performance runtime** specifically for the CLI output.
36
+
37
+ ### 1. Setup the Provider (Root Layout)
38
+ No need to move files into `[locale]` folders. Just wrap your layout.
39
+
40
+ ```tsx
41
+ // app/layout.tsx
42
+ import { I18nProvider } from "@scopeact/autoi18n/client";
43
+ import { getI18nConfig } from "@scopeact/autoi18n/server";
44
+
45
+ export default async function RootLayout({ children }) {
46
+ const i18n = await getI18nConfig('en'); // Default language
47
+
48
+ return (
49
+ <html lang={i18n.locale}>
50
+ <body>
51
+ <I18nProvider locale={i18n.locale} messages={i18n.messages}>
52
+ {children}
53
+ </I18nProvider>
54
+ </body>
55
+ </html>
56
+ );
57
+ }
58
+ ```
59
+
60
+ ### 2. Usage in Server Components
61
+ ```tsx
62
+ // app/page.tsx (Server)
63
+ import { getI18n } from '@scopeact/autoi18n/server';
64
+
65
+ export default async function Page() {
66
+ const { t } = await getI18n();
67
+ return <h1>{t("hero_title")}</h1>;
68
+ }
69
+ ```
70
+
71
+ ### 3. Usage in Client Components
72
+ ```tsx
73
+ // components/Button.tsx (Client)
74
+ 'use client';
75
+ import { useI18n } from '@scopeact/autoi18n/client';
76
+
77
+ export function HeroButton() {
78
+ const { t } = useI18n();
79
+ return <button>{t("get_started")}</button>;
80
+ }
81
+ ```
82
+
83
+ ---
84
+
85
+ ## ๐Ÿ›  Configuration
86
+
87
+ Created via `init`, the `auto-i18n.config.json` controls the magic:
88
+
89
+ ```json
90
+ {
91
+ "sourceLang": "pt",
92
+ "targetLangs": ["en", "es"],
93
+ "i18nLibrary": "@scopeact/autoi18n",
94
+ "provider": "openai",
95
+ "localesDir": "./locales",
96
+ "files": ["src/**/*.tsx"]
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ## ๐Ÿ’Ž Why autoi18n?
103
+
104
+ | Feature | Tradicional (next-intl/i18next) | **autoi18n** |
105
+ | :--- | :--- | :--- |
106
+ | **Key Creation** | Manual (Hours of copy-paste) | **AI-Automated** (Seconds) |
107
+ | **Code Rewrite** | Manual | **AST-Automated** |
108
+ | **Folder Structure** | Forced `[locale]` nesting | **Stay as you are** |
109
+ | **Next.js Setup** | Complex (Middleware/Config) | **Zero-Config** |
110
+
111
+ ---
112
+
113
+ ## ๐Ÿ‡ง๐Ÿ‡ท Born in Brazil
114
+ Projeto desenvolvido com foco em resolver a dor real de desenvolvedores que precisam entregar projetos globais rรกpido.
115
+
116
+ ## License
117
+ MIT ยฉ [Felipe Vetter](https://github.com/felipevetter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scopeact/autoi18n",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Auto i18n tool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",