@intlayer/vue-transformer 7.3.0

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.
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ <p align="center">
2
+ <a href="https://intlayer.org" rel="">
3
+ <img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" width="60%" alt="Intlayer Logo" />
4
+ </a>
5
+ </p>
6
+
7
+ <h1 align="center">
8
+ <strong> Intlayer : an Open-source, per-component i18n toolkit with AI-powered translation & CMS.</strong>
9
+ </h1>
10
+
11
+ <br />
12
+
13
+ <p align="center">
14
+ <a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
15
+ <a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
16
+ <a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
17
+ <a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
18
+ <a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
19
+ </p>
20
+ <p align="center" style="margin-top:15px;">
21
+ <a href="https://www.npmjs.com/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/intlayer?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
22
+ <a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
23
+ <a href="https://www.npmjs.org/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="monthly downloads" height="24"/></a>
24
+ <a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="license"/></a>
25
+ <a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="last commit"/>
26
+ </a>
27
+ <a href="https://bountyhub.dev/bounties?repo=intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/badge/Bounties-on%20BountyHub-yellow?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="Bounties on BountyHub"/>
28
+ </a>
29
+ </p>
30
+
31
+ ![Watch the video](https://github.com/aymericzip/intlayer/blob/main/docs/assets/demo_video.gif)
32
+
33
+ <a href="https://intlayer.org/doc/concept/content" rel="">
34
+ <img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
35
+ </a>
36
+
37
+ ## What is Intlayer?
38
+
39
+ Most i18n libraries are either too complex, too rigid, or not built for modern frameworks.
40
+
41
+ Intlayer is a **modern i18n solution** for web and mobile apps.
42
+ It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**.
43
+
44
+ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
45
+
46
+ ## Keys benefits of Intlayer:
47
+
48
+ | Feature | Description |
49
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
50
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
51
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.png?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
52
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
53
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
54
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
55
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
56
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
57
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
58
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
59
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
60
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
61
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
62
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
63
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
64
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
65
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
66
+ | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, and react-intl. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) |
67
+
68
+ ---
69
+
70
+ ## 📦 Installation
71
+
72
+ Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
73
+
74
+ <a href="https://intlayer.org/doc/concept/content" rel="">
75
+ <img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
76
+ </a>
77
+
78
+ ```bash
79
+ npm install intlayer react-intlayer
80
+ ```
81
+
82
+ ⚡ Quick Start (Next.js)
83
+
84
+ ```ts
85
+ // intlayer.config.ts
86
+ import { Locales, type IntlayerConfig } from "intlayer";
87
+
88
+ const config: IntlayerConfig = {
89
+ internationalization: {
90
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
91
+ defaultLocale: Locales.ENGLISH,
92
+ },
93
+ };
94
+
95
+ export default config;
96
+ ```
97
+
98
+ ```ts
99
+ // app/home.content.ts
100
+ import { t, type Dictionary } from "intlayer";
101
+
102
+ const content = {
103
+ key: "home",
104
+ content: {
105
+ title: t({
106
+ en: "Home",
107
+ fr: "Accueil",
108
+ es: "Inicio",
109
+ }),
110
+ },
111
+ } satisfies Dictionary;
112
+
113
+ export default content;
114
+ ```
115
+
116
+ ```tsx
117
+ // app/page.tsx
118
+ import { useIntlayer } from "react-intlayer";
119
+
120
+ const HomePage = () => {
121
+ const { title } = useIntlayer("home");
122
+
123
+ return <h1>{title}</h1>;
124
+ };
125
+ ```
126
+
127
+ <a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
128
+
129
+ ## 🎥 Live tutorial on YouTube
130
+
131
+ [![How to Internationalize your application using Intlayer](https://i.ytimg.com/vi/e_PPG7PTqGU/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDtyJ4uYotEjl12nZ_gZKZ_kjEgOQ)](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
132
+
133
+ <a href="https://intlayer.org/doc/concept/content" rel="">
134
+ <img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
135
+ </a>
136
+
137
+ ## Table of Contents
138
+
139
+ Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
140
+
141
+ <details open>
142
+ <summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
143
+ <ul>
144
+ <li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
145
+ <li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
146
+ </ul>
147
+ </details>
148
+
149
+ <details>
150
+ <summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
151
+ <ul>
152
+ <li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
153
+ <li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
154
+ <li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
155
+ <li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
156
+ <li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
157
+ <li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
158
+ <ul>
159
+ <li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
160
+ <li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
161
+ <li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
162
+ <li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
163
+ <li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
164
+ <li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
165
+ <li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
166
+ <li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
167
+ <li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
168
+ </ul>
169
+ </li>
170
+ </ul>
171
+ </details>
172
+
173
+ <details open>
174
+ <summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
175
+ <ul>
176
+ <li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
177
+ <ul>
178
+ <li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
179
+ <li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
180
+ <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
181
+ </ul>
182
+ </li>
183
+ <li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
184
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a>
185
+ <ul>
186
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
187
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react/tanstack-start" rel=''>Tanstack start</a></li>
188
+ </ul>
189
+ </li>
190
+ <li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
191
+ <li><a href="https://intlayer.org/doc/environment/lynx-and-react" rel=''>Lynx + React</a></li>
192
+ <li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
193
+ <li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
194
+ <li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
195
+ <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
196
+ <li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
197
+ <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
198
+ <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
199
+ <li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
200
+ <li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
201
+ </ul>
202
+ </details>
203
+
204
+ <details>
205
+ <summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
206
+ <ul>
207
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
208
+ <li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
209
+ <li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
210
+ <li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
211
+ <li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
212
+ </ul>
213
+ </details>
214
+
215
+ ## 🌐 Readme in other languages
216
+
217
+ <p align="center">
218
+ <a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
219
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
220
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
221
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
222
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
223
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
224
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
225
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
226
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
227
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
228
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
229
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
230
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
231
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
232
+ </p>
233
+
234
+ ## 🤝 Community
235
+
236
+ Intlayer is built with and for the community and we’d love your input!
237
+
238
+ - Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
239
+ - Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
240
+ - Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
241
+
242
+ You can also follow us on :
243
+
244
+ <div>
245
+ <br/>
246
+ <p align="center">
247
+ <a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
248
+ src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
249
+ alt="Intlayer Discord" height="30"/></a>
250
+ <a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
251
+ src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
252
+ alt="Intlayer LinkedIn" height="30"/></a>
253
+ <a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
254
+ src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
255
+ alt="Intlayer Instagram" height="30"/></a>
256
+ <a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
257
+ src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
258
+ alt="Intlayer X" height="30"/></a>
259
+ <a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
260
+ src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
261
+ alt="Intlayer YouTube" height="30"/></a>
262
+ <a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
263
+ src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
264
+ alt="Intlayer TikTok" height="30"/></a>
265
+ <br>
266
+ </p>
267
+ </div>
268
+
269
+ ### Contribution
270
+
271
+ For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
272
+
273
+ ### Thank You for the Support
274
+
275
+ If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
276
+
277
+ [![Star History Chart](https://api.star-history.com/svg?repos=aymericzip/intlayer&type=Date)](https://star-history.com/#aymericzip/intlayer&Date)
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -0,0 +1,72 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let node_fs_promises = require("node:fs/promises");
3
+ let __vue_compiler_sfc = require("@vue/compiler-sfc");
4
+ let magic_string = require("magic-string");
5
+ magic_string = require_rolldown_runtime.__toESM(magic_string);
6
+ let ts_morph = require("ts-morph");
7
+
8
+ //#region src/index.ts
9
+ const ATTRIBUTES_TO_EXTRACT = [
10
+ "title",
11
+ "placeholder",
12
+ "alt",
13
+ "aria-label",
14
+ "label"
15
+ ];
16
+ const processVueFile = async (filePath, componentKey, packageName, tools, save = true) => {
17
+ const { generateKey, shouldExtract, extractTsContent } = tools;
18
+ const code = await (0, node_fs_promises.readFile)(filePath, "utf-8");
19
+ const sfc = (0, __vue_compiler_sfc.parse)(code);
20
+ const magic = new magic_string.default(code);
21
+ const extractedContent = {};
22
+ const existingKeys = /* @__PURE__ */ new Set();
23
+ if (sfc.descriptor.template) {
24
+ const walkVueAst = (node) => {
25
+ if (node.type === 2) {
26
+ const text = node.content;
27
+ if (shouldExtract(text)) {
28
+ const key = generateKey(text, existingKeys);
29
+ existingKeys.add(key);
30
+ extractedContent[key] = text.replace(/\s+/g, " ").trim();
31
+ magic.overwrite(node.loc.start.offset, node.loc.end.offset, `{{ content.${key} }}`);
32
+ }
33
+ } else if (node.type === 1) node.props.forEach((prop) => {
34
+ if (prop.type === 6 && ATTRIBUTES_TO_EXTRACT.includes(prop.name) && prop.value) {
35
+ const text = prop.value.content;
36
+ if (shouldExtract(text)) {
37
+ const key = generateKey(text, existingKeys);
38
+ existingKeys.add(key);
39
+ extractedContent[key] = text.trim();
40
+ magic.overwrite(prop.loc.start.offset, prop.loc.end.offset, `:${prop.name}="content.${key}"`);
41
+ }
42
+ }
43
+ });
44
+ if (node.children) node.children.forEach(walkVueAst);
45
+ };
46
+ walkVueAst(sfc.descriptor.template.ast);
47
+ }
48
+ const scriptBlock = sfc.descriptor.scriptSetup || sfc.descriptor.script;
49
+ if (scriptBlock) {
50
+ const scriptContent = scriptBlock.content;
51
+ const scriptOffset = scriptBlock.loc.start.offset;
52
+ const { extractedContent: scriptExtracted, replacements } = extractTsContent(new ts_morph.Project({ skipAddingFilesFromTsConfig: true }).createSourceFile("temp.ts", scriptContent), existingKeys);
53
+ Object.assign(extractedContent, scriptExtracted);
54
+ for (const { node, key } of replacements) {
55
+ const start = scriptOffset + node.getStart();
56
+ const end = scriptOffset + node.getEnd();
57
+ magic.overwrite(start, end, `content.${key}`);
58
+ }
59
+ }
60
+ if (Object.keys(extractedContent).length === 0) return null;
61
+ const importStmt = `import { useIntlayer } from '${packageName}';`;
62
+ const contentDecl = `const content = useIntlayer('${componentKey}');`;
63
+ if (sfc.descriptor.scriptSetup) magic.appendLeft(sfc.descriptor.scriptSetup.loc.start.offset, `\n${importStmt}\n${contentDecl}\n`);
64
+ else if (sfc.descriptor.script) magic.appendLeft(sfc.descriptor.script.loc.start.offset, `\n${importStmt}\n${contentDecl}\n`);
65
+ else magic.prepend(`<script setup>\n${importStmt}\n${contentDecl}\n<\/script>\n`);
66
+ if (save) await (0, node_fs_promises.writeFile)(filePath, magic.toString());
67
+ return extractedContent;
68
+ };
69
+
70
+ //#endregion
71
+ exports.processVueFile = processVueFile;
72
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["MagicString","extractedContent: Record<string, string>","Project"],"sources":["../../src/index.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { parse as parseVue } from '@vue/compiler-sfc';\nimport MagicString from 'magic-string';\nimport { type Node, Project, type SourceFile } from 'ts-morph';\n\ntype TsReplacement = {\n node: Node;\n key: string;\n type: 'jsx-text' | 'jsx-attribute' | 'string-literal';\n};\n\ntype Tools = {\n generateKey: (text: string, existingKeys: Set<string>) => string;\n shouldExtract: (text: string) => boolean;\n extractTsContent: (\n sourceFile: SourceFile,\n existingKeys: Set<string>\n ) => {\n extractedContent: Record<string, string>;\n replacements: TsReplacement[];\n };\n};\n\n// Kept local as it's specific to Vue attributes, though shared list is 'title', 'placeholder' etc.\n// If we want to strictly mutualize, we can pass it too.\nconst ATTRIBUTES_TO_EXTRACT = [\n 'title',\n 'placeholder',\n 'alt',\n 'aria-label',\n 'label',\n];\n\nexport const processVueFile = async (\n filePath: string,\n componentKey: string,\n packageName: string,\n tools: Tools,\n save: boolean = true\n) => {\n const { generateKey, shouldExtract, extractTsContent } = tools;\n const code = await readFile(filePath, 'utf-8');\n const sfc = parseVue(code);\n const magic = new MagicString(code);\n\n const extractedContent: Record<string, string> = {};\n const existingKeys = new Set<string>();\n\n // 3a. Template Extraction\n if (sfc.descriptor.template) {\n const walkVueAst = (node: any) => {\n if (node.type === 2) {\n // NodeTypes.TEXT\n const text = node.content;\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.replace(/\\s+/g, ' ').trim();\n magic.overwrite(\n node.loc.start.offset,\n node.loc.end.offset,\n `{{ content.${key} }}`\n );\n }\n } else if (node.type === 1) {\n // NodeTypes.ELEMENT\n node.props.forEach((prop: any) => {\n if (\n prop.type === 6 && // NodeTypes.ATTRIBUTE\n ATTRIBUTES_TO_EXTRACT.includes(prop.name) &&\n prop.value\n ) {\n const text = prop.value.content;\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n magic.overwrite(\n prop.loc.start.offset,\n prop.loc.end.offset,\n `:${prop.name}=\"content.${key}\"`\n );\n }\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(walkVueAst);\n }\n };\n walkVueAst(sfc.descriptor.template.ast);\n }\n\n // 3b. Script Extraction\n const scriptBlock = sfc.descriptor.scriptSetup || sfc.descriptor.script;\n if (scriptBlock) {\n const scriptContent = scriptBlock.content;\n const scriptOffset = scriptBlock.loc.start.offset;\n const project = new Project({ skipAddingFilesFromTsConfig: true });\n const sourceFile = project.createSourceFile('temp.ts', scriptContent);\n\n const { extractedContent: scriptExtracted, replacements } =\n extractTsContent(sourceFile, existingKeys);\n Object.assign(extractedContent, scriptExtracted);\n\n for (const { node, key } of replacements) {\n // Calculate absolute pos\n const start = scriptOffset + node.getStart();\n const end = scriptOffset + node.getEnd();\n magic.overwrite(start, end, `content.${key}`);\n }\n }\n\n if (Object.keys(extractedContent).length === 0) return null;\n\n // Inject Script\n const importStmt = `import { useIntlayer } from '${packageName}';`;\n const contentDecl = `const content = useIntlayer('${componentKey}');`;\n\n if (sfc.descriptor.scriptSetup) {\n magic.appendLeft(\n sfc.descriptor.scriptSetup.loc.start.offset,\n `\\n${importStmt}\\n${contentDecl}\\n`\n );\n } else if (sfc.descriptor.script) {\n magic.appendLeft(\n sfc.descriptor.script.loc.start.offset,\n `\\n${importStmt}\\n${contentDecl}\\n`\n );\n } else {\n magic.prepend(`<script setup>\\n${importStmt}\\n${contentDecl}\\n</script>\\n`);\n }\n\n if (save) {\n await writeFile(filePath, magic.toString());\n }\n return extractedContent;\n};\n"],"mappings":";;;;;;;;AAyBA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,iBAAiB,OAC5B,UACA,cACA,aACA,OACA,OAAgB,SACb;CACH,MAAM,EAAE,aAAa,eAAe,qBAAqB;CACzD,MAAM,OAAO,qCAAe,UAAU,QAAQ;CAC9C,MAAM,oCAAe,KAAK;CAC1B,MAAM,QAAQ,IAAIA,qBAAY,KAAK;CAEnC,MAAMC,mBAA2C,EAAE;CACnD,MAAM,+BAAe,IAAI,KAAa;AAGtC,KAAI,IAAI,WAAW,UAAU;EAC3B,MAAM,cAAc,SAAc;AAChC,OAAI,KAAK,SAAS,GAAG;IAEnB,MAAM,OAAO,KAAK;AAClB,QAAI,cAAc,KAAK,EAAE;KACvB,MAAM,MAAM,YAAY,MAAM,aAAa;AAC3C,kBAAa,IAAI,IAAI;AACrB,sBAAiB,OAAO,KAAK,QAAQ,QAAQ,IAAI,CAAC,MAAM;AACxD,WAAM,UACJ,KAAK,IAAI,MAAM,QACf,KAAK,IAAI,IAAI,QACb,cAAc,IAAI,KACnB;;cAEM,KAAK,SAAS,EAEvB,MAAK,MAAM,SAAS,SAAc;AAChC,QACE,KAAK,SAAS,KACd,sBAAsB,SAAS,KAAK,KAAK,IACzC,KAAK,OACL;KACA,MAAM,OAAO,KAAK,MAAM;AACxB,SAAI,cAAc,KAAK,EAAE;MACvB,MAAM,MAAM,YAAY,MAAM,aAAa;AAC3C,mBAAa,IAAI,IAAI;AACrB,uBAAiB,OAAO,KAAK,MAAM;AACnC,YAAM,UACJ,KAAK,IAAI,MAAM,QACf,KAAK,IAAI,IAAI,QACb,IAAI,KAAK,KAAK,YAAY,IAAI,GAC/B;;;KAGL;AAGJ,OAAI,KAAK,SACP,MAAK,SAAS,QAAQ,WAAW;;AAGrC,aAAW,IAAI,WAAW,SAAS,IAAI;;CAIzC,MAAM,cAAc,IAAI,WAAW,eAAe,IAAI,WAAW;AACjE,KAAI,aAAa;EACf,MAAM,gBAAgB,YAAY;EAClC,MAAM,eAAe,YAAY,IAAI,MAAM;EAI3C,MAAM,EAAE,kBAAkB,iBAAiB,iBACzC,iBAJc,IAAIC,iBAAQ,EAAE,6BAA6B,MAAM,CAAC,CACvC,iBAAiB,WAAW,cAAc,EAGtC,aAAa;AAC5C,SAAO,OAAO,kBAAkB,gBAAgB;AAEhD,OAAK,MAAM,EAAE,MAAM,SAAS,cAAc;GAExC,MAAM,QAAQ,eAAe,KAAK,UAAU;GAC5C,MAAM,MAAM,eAAe,KAAK,QAAQ;AACxC,SAAM,UAAU,OAAO,KAAK,WAAW,MAAM;;;AAIjD,KAAI,OAAO,KAAK,iBAAiB,CAAC,WAAW,EAAG,QAAO;CAGvD,MAAM,aAAa,gCAAgC,YAAY;CAC/D,MAAM,cAAc,gCAAgC,aAAa;AAEjE,KAAI,IAAI,WAAW,YACjB,OAAM,WACJ,IAAI,WAAW,YAAY,IAAI,MAAM,QACrC,KAAK,WAAW,IAAI,YAAY,IACjC;UACQ,IAAI,WAAW,OACxB,OAAM,WACJ,IAAI,WAAW,OAAO,IAAI,MAAM,QAChC,KAAK,WAAW,IAAI,YAAY,IACjC;KAED,OAAM,QAAQ,mBAAmB,WAAW,IAAI,YAAY,gBAAe;AAG7E,KAAI,KACF,uCAAgB,UAAU,MAAM,UAAU,CAAC;AAE7C,QAAO"}
@@ -0,0 +1,70 @@
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { parse } from "@vue/compiler-sfc";
3
+ import MagicString from "magic-string";
4
+ import { Project } from "ts-morph";
5
+
6
+ //#region src/index.ts
7
+ const ATTRIBUTES_TO_EXTRACT = [
8
+ "title",
9
+ "placeholder",
10
+ "alt",
11
+ "aria-label",
12
+ "label"
13
+ ];
14
+ const processVueFile = async (filePath, componentKey, packageName, tools, save = true) => {
15
+ const { generateKey, shouldExtract, extractTsContent } = tools;
16
+ const code = await readFile(filePath, "utf-8");
17
+ const sfc = parse(code);
18
+ const magic = new MagicString(code);
19
+ const extractedContent = {};
20
+ const existingKeys = /* @__PURE__ */ new Set();
21
+ if (sfc.descriptor.template) {
22
+ const walkVueAst = (node) => {
23
+ if (node.type === 2) {
24
+ const text = node.content;
25
+ if (shouldExtract(text)) {
26
+ const key = generateKey(text, existingKeys);
27
+ existingKeys.add(key);
28
+ extractedContent[key] = text.replace(/\s+/g, " ").trim();
29
+ magic.overwrite(node.loc.start.offset, node.loc.end.offset, `{{ content.${key} }}`);
30
+ }
31
+ } else if (node.type === 1) node.props.forEach((prop) => {
32
+ if (prop.type === 6 && ATTRIBUTES_TO_EXTRACT.includes(prop.name) && prop.value) {
33
+ const text = prop.value.content;
34
+ if (shouldExtract(text)) {
35
+ const key = generateKey(text, existingKeys);
36
+ existingKeys.add(key);
37
+ extractedContent[key] = text.trim();
38
+ magic.overwrite(prop.loc.start.offset, prop.loc.end.offset, `:${prop.name}="content.${key}"`);
39
+ }
40
+ }
41
+ });
42
+ if (node.children) node.children.forEach(walkVueAst);
43
+ };
44
+ walkVueAst(sfc.descriptor.template.ast);
45
+ }
46
+ const scriptBlock = sfc.descriptor.scriptSetup || sfc.descriptor.script;
47
+ if (scriptBlock) {
48
+ const scriptContent = scriptBlock.content;
49
+ const scriptOffset = scriptBlock.loc.start.offset;
50
+ const { extractedContent: scriptExtracted, replacements } = extractTsContent(new Project({ skipAddingFilesFromTsConfig: true }).createSourceFile("temp.ts", scriptContent), existingKeys);
51
+ Object.assign(extractedContent, scriptExtracted);
52
+ for (const { node, key } of replacements) {
53
+ const start = scriptOffset + node.getStart();
54
+ const end = scriptOffset + node.getEnd();
55
+ magic.overwrite(start, end, `content.${key}`);
56
+ }
57
+ }
58
+ if (Object.keys(extractedContent).length === 0) return null;
59
+ const importStmt = `import { useIntlayer } from '${packageName}';`;
60
+ const contentDecl = `const content = useIntlayer('${componentKey}');`;
61
+ if (sfc.descriptor.scriptSetup) magic.appendLeft(sfc.descriptor.scriptSetup.loc.start.offset, `\n${importStmt}\n${contentDecl}\n`);
62
+ else if (sfc.descriptor.script) magic.appendLeft(sfc.descriptor.script.loc.start.offset, `\n${importStmt}\n${contentDecl}\n`);
63
+ else magic.prepend(`<script setup>\n${importStmt}\n${contentDecl}\n<\/script>\n`);
64
+ if (save) await writeFile(filePath, magic.toString());
65
+ return extractedContent;
66
+ };
67
+
68
+ //#endregion
69
+ export { processVueFile };
70
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["parseVue","extractedContent: Record<string, string>"],"sources":["../../src/index.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { parse as parseVue } from '@vue/compiler-sfc';\nimport MagicString from 'magic-string';\nimport { type Node, Project, type SourceFile } from 'ts-morph';\n\ntype TsReplacement = {\n node: Node;\n key: string;\n type: 'jsx-text' | 'jsx-attribute' | 'string-literal';\n};\n\ntype Tools = {\n generateKey: (text: string, existingKeys: Set<string>) => string;\n shouldExtract: (text: string) => boolean;\n extractTsContent: (\n sourceFile: SourceFile,\n existingKeys: Set<string>\n ) => {\n extractedContent: Record<string, string>;\n replacements: TsReplacement[];\n };\n};\n\n// Kept local as it's specific to Vue attributes, though shared list is 'title', 'placeholder' etc.\n// If we want to strictly mutualize, we can pass it too.\nconst ATTRIBUTES_TO_EXTRACT = [\n 'title',\n 'placeholder',\n 'alt',\n 'aria-label',\n 'label',\n];\n\nexport const processVueFile = async (\n filePath: string,\n componentKey: string,\n packageName: string,\n tools: Tools,\n save: boolean = true\n) => {\n const { generateKey, shouldExtract, extractTsContent } = tools;\n const code = await readFile(filePath, 'utf-8');\n const sfc = parseVue(code);\n const magic = new MagicString(code);\n\n const extractedContent: Record<string, string> = {};\n const existingKeys = new Set<string>();\n\n // 3a. Template Extraction\n if (sfc.descriptor.template) {\n const walkVueAst = (node: any) => {\n if (node.type === 2) {\n // NodeTypes.TEXT\n const text = node.content;\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.replace(/\\s+/g, ' ').trim();\n magic.overwrite(\n node.loc.start.offset,\n node.loc.end.offset,\n `{{ content.${key} }}`\n );\n }\n } else if (node.type === 1) {\n // NodeTypes.ELEMENT\n node.props.forEach((prop: any) => {\n if (\n prop.type === 6 && // NodeTypes.ATTRIBUTE\n ATTRIBUTES_TO_EXTRACT.includes(prop.name) &&\n prop.value\n ) {\n const text = prop.value.content;\n if (shouldExtract(text)) {\n const key = generateKey(text, existingKeys);\n existingKeys.add(key);\n extractedContent[key] = text.trim();\n magic.overwrite(\n prop.loc.start.offset,\n prop.loc.end.offset,\n `:${prop.name}=\"content.${key}\"`\n );\n }\n }\n });\n }\n\n if (node.children) {\n node.children.forEach(walkVueAst);\n }\n };\n walkVueAst(sfc.descriptor.template.ast);\n }\n\n // 3b. Script Extraction\n const scriptBlock = sfc.descriptor.scriptSetup || sfc.descriptor.script;\n if (scriptBlock) {\n const scriptContent = scriptBlock.content;\n const scriptOffset = scriptBlock.loc.start.offset;\n const project = new Project({ skipAddingFilesFromTsConfig: true });\n const sourceFile = project.createSourceFile('temp.ts', scriptContent);\n\n const { extractedContent: scriptExtracted, replacements } =\n extractTsContent(sourceFile, existingKeys);\n Object.assign(extractedContent, scriptExtracted);\n\n for (const { node, key } of replacements) {\n // Calculate absolute pos\n const start = scriptOffset + node.getStart();\n const end = scriptOffset + node.getEnd();\n magic.overwrite(start, end, `content.${key}`);\n }\n }\n\n if (Object.keys(extractedContent).length === 0) return null;\n\n // Inject Script\n const importStmt = `import { useIntlayer } from '${packageName}';`;\n const contentDecl = `const content = useIntlayer('${componentKey}');`;\n\n if (sfc.descriptor.scriptSetup) {\n magic.appendLeft(\n sfc.descriptor.scriptSetup.loc.start.offset,\n `\\n${importStmt}\\n${contentDecl}\\n`\n );\n } else if (sfc.descriptor.script) {\n magic.appendLeft(\n sfc.descriptor.script.loc.start.offset,\n `\\n${importStmt}\\n${contentDecl}\\n`\n );\n } else {\n magic.prepend(`<script setup>\\n${importStmt}\\n${contentDecl}\\n</script>\\n`);\n }\n\n if (save) {\n await writeFile(filePath, magic.toString());\n }\n return extractedContent;\n};\n"],"mappings":";;;;;;AAyBA,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,iBAAiB,OAC5B,UACA,cACA,aACA,OACA,OAAgB,SACb;CACH,MAAM,EAAE,aAAa,eAAe,qBAAqB;CACzD,MAAM,OAAO,MAAM,SAAS,UAAU,QAAQ;CAC9C,MAAM,MAAMA,MAAS,KAAK;CAC1B,MAAM,QAAQ,IAAI,YAAY,KAAK;CAEnC,MAAMC,mBAA2C,EAAE;CACnD,MAAM,+BAAe,IAAI,KAAa;AAGtC,KAAI,IAAI,WAAW,UAAU;EAC3B,MAAM,cAAc,SAAc;AAChC,OAAI,KAAK,SAAS,GAAG;IAEnB,MAAM,OAAO,KAAK;AAClB,QAAI,cAAc,KAAK,EAAE;KACvB,MAAM,MAAM,YAAY,MAAM,aAAa;AAC3C,kBAAa,IAAI,IAAI;AACrB,sBAAiB,OAAO,KAAK,QAAQ,QAAQ,IAAI,CAAC,MAAM;AACxD,WAAM,UACJ,KAAK,IAAI,MAAM,QACf,KAAK,IAAI,IAAI,QACb,cAAc,IAAI,KACnB;;cAEM,KAAK,SAAS,EAEvB,MAAK,MAAM,SAAS,SAAc;AAChC,QACE,KAAK,SAAS,KACd,sBAAsB,SAAS,KAAK,KAAK,IACzC,KAAK,OACL;KACA,MAAM,OAAO,KAAK,MAAM;AACxB,SAAI,cAAc,KAAK,EAAE;MACvB,MAAM,MAAM,YAAY,MAAM,aAAa;AAC3C,mBAAa,IAAI,IAAI;AACrB,uBAAiB,OAAO,KAAK,MAAM;AACnC,YAAM,UACJ,KAAK,IAAI,MAAM,QACf,KAAK,IAAI,IAAI,QACb,IAAI,KAAK,KAAK,YAAY,IAAI,GAC/B;;;KAGL;AAGJ,OAAI,KAAK,SACP,MAAK,SAAS,QAAQ,WAAW;;AAGrC,aAAW,IAAI,WAAW,SAAS,IAAI;;CAIzC,MAAM,cAAc,IAAI,WAAW,eAAe,IAAI,WAAW;AACjE,KAAI,aAAa;EACf,MAAM,gBAAgB,YAAY;EAClC,MAAM,eAAe,YAAY,IAAI,MAAM;EAI3C,MAAM,EAAE,kBAAkB,iBAAiB,iBACzC,iBAJc,IAAI,QAAQ,EAAE,6BAA6B,MAAM,CAAC,CACvC,iBAAiB,WAAW,cAAc,EAGtC,aAAa;AAC5C,SAAO,OAAO,kBAAkB,gBAAgB;AAEhD,OAAK,MAAM,EAAE,MAAM,SAAS,cAAc;GAExC,MAAM,QAAQ,eAAe,KAAK,UAAU;GAC5C,MAAM,MAAM,eAAe,KAAK,QAAQ;AACxC,SAAM,UAAU,OAAO,KAAK,WAAW,MAAM;;;AAIjD,KAAI,OAAO,KAAK,iBAAiB,CAAC,WAAW,EAAG,QAAO;CAGvD,MAAM,aAAa,gCAAgC,YAAY;CAC/D,MAAM,cAAc,gCAAgC,aAAa;AAEjE,KAAI,IAAI,WAAW,YACjB,OAAM,WACJ,IAAI,WAAW,YAAY,IAAI,MAAM,QACrC,KAAK,WAAW,IAAI,YAAY,IACjC;UACQ,IAAI,WAAW,OACxB,OAAM,WACJ,IAAI,WAAW,OAAO,IAAI,MAAM,QAChC,KAAK,WAAW,IAAI,YAAY,IACjC;KAED,OAAM,QAAQ,mBAAmB,WAAW,IAAI,YAAY,gBAAe;AAG7E,KAAI,KACF,OAAM,UAAU,UAAU,MAAM,UAAU,CAAC;AAE7C,QAAO"}
@@ -0,0 +1,20 @@
1
+ import { Node, SourceFile } from "ts-morph";
2
+
3
+ //#region src/index.d.ts
4
+ type TsReplacement = {
5
+ node: Node;
6
+ key: string;
7
+ type: 'jsx-text' | 'jsx-attribute' | 'string-literal';
8
+ };
9
+ type Tools = {
10
+ generateKey: (text: string, existingKeys: Set<string>) => string;
11
+ shouldExtract: (text: string) => boolean;
12
+ extractTsContent: (sourceFile: SourceFile, existingKeys: Set<string>) => {
13
+ extractedContent: Record<string, string>;
14
+ replacements: TsReplacement[];
15
+ };
16
+ };
17
+ declare const processVueFile: (filePath: string, componentKey: string, packageName: string, tools: Tools, save?: boolean) => Promise<Record<string, string>>;
18
+ //#endregion
19
+ export { processVueFile };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"sourcesContent":[],"mappings":";;;KAKK,aAAA;QACG;EADH,GAAA,EAAA,MAAA;EAMA,IAAA,EAAA,UAAK,GAAA,eAAA,GAAA,gBAAA;CACkC;KADvC,KAAA,GAIW;EACE,WAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,YAAA,EAJ0B,GAI1B,CAAA,MAAA,CAAA,EAAA,GAAA,MAAA;EAEI,aAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,OAAA;EACJ,gBAAA,EAAA,CAAA,UAAA,EAJF,UAIE,EAAA,YAAA,EAHA,GAGA,CAAA,MAAA,CAAA,EAAA,GAAA;IAAa,gBAAA,EADT,MACS,CAAA,MAAA,EAAA,MAAA,CAAA;IAclB,YAAA,EAdK,aAuHjB,EAAA;EArGQ,CAAA;CACa;AAAA,cALT,cAKS,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,WAAA,EAAA,MAAA,EAAA,KAAA,EADb,KACa,EAAA,IAAA,CAAA,EAAA,OAAA,EAAA,GAAA,OAAA,CAAA,MAAA,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@intlayer/vue-transformer",
3
+ "version": "7.3.0",
4
+ "private": false,
5
+ "description": "A transformer for Intlayer that extract strings from Vue components.",
6
+ "keywords": [
7
+ "intlayer",
8
+ "vue",
9
+ "transformer"
10
+ ],
11
+ "homepage": "https://intlayer.org",
12
+ "bugs": {
13
+ "url": "https://github.com/aymericzip/intlayer/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/aymericzip/intlayer.git"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "author": {
21
+ "name": "Aymeric PINEAU",
22
+ "url": "https://github.com/aymericzip"
23
+ },
24
+ "contributors": [
25
+ {
26
+ "name": "Aymeric Pineau",
27
+ "email": "ay.pineau@gmail.com",
28
+ "url": "https://github.com/aymericzip"
29
+ }
30
+ ],
31
+ "sideEffects": false,
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/types/index.d.ts",
35
+ "require": "./dist/cjs/index.cjs",
36
+ "import": "./dist/esm/index.mjs"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "main": "dist/cjs/index.cjs",
41
+ "module": "dist/esm/index.mjs",
42
+ "types": "dist/types/index.d.ts",
43
+ "typesVersions": {
44
+ "*": {
45
+ "package.json": [
46
+ "./package.json"
47
+ ]
48
+ }
49
+ },
50
+ "files": [
51
+ "./dist",
52
+ "./package.json"
53
+ ],
54
+ "scripts": {
55
+ "build": "tsdown --config tsdown.config.ts",
56
+ "build:ci": "tsdown --config tsdown.config.ts",
57
+ "clean": "rimraf ./dist .turbo",
58
+ "dev": "tsdown --config tsdown.config.ts --watch",
59
+ "format": "biome format . --check",
60
+ "format:fix": "biome format --write .",
61
+ "lint": "biome lint .",
62
+ "lint:fix": "biome lint --write .",
63
+ "process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
64
+ "prepublish": "cp -f ../../README.md ./README.md",
65
+ "publish": "bun publish || true",
66
+ "publish:canary": "bun publish --access public --tag canary || true",
67
+ "publish:latest": "bun publish --access public --tag latest || true",
68
+ "test": "vitest run",
69
+ "test:watch": "vitest",
70
+ "typecheck": "tsc --noEmit --project tsconfig.types.json"
71
+ },
72
+ "dependencies": {
73
+ "@vue/compiler-sfc": "^3.4.21",
74
+ "magic-string": "^0.30.8",
75
+ "ts-morph": "^27.0.0"
76
+ },
77
+ "devDependencies": {
78
+ "@types/node": "24.10.1",
79
+ "@utils/ts-config": "1.0.4",
80
+ "@utils/ts-config-types": "1.0.4",
81
+ "@utils/tsdown-config": "1.0.4",
82
+ "rimraf": "6.1.2",
83
+ "tsdown": "0.16.6",
84
+ "typescript": "5.9.3",
85
+ "vitest": "4.0.13"
86
+ },
87
+ "engines": {
88
+ "node": ">=14.18"
89
+ },
90
+ "bug": {
91
+ "url": "https://github.com/aymericzip/intlayer/issues"
92
+ }
93
+ }