@uipkge/nuxt 0.1.25 → 0.1.30

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/bin/cli.mjs CHANGED
@@ -18,110 +18,39 @@ function exists(file) {
18
18
  return fs.existsSync(path.join(TARGET_DIR, file))
19
19
  }
20
20
 
21
- console.log('\n🚀 Setting up @uipkge/nuxt in', TARGET_DIR, '\n')
21
+ console.log('\n🚀 @uipkge/nuxt setup\n')
22
22
 
23
23
  if (isInstalled) {
24
- console.log('📦 @uipkge/nuxt already built, skipping build step')
24
+ console.log('📦 Package ready')
25
25
  } else {
26
- console.log('📦 Building @uipkge/nuxt...')
26
+ console.log('📦 Building package...')
27
27
  run('npm run build', { cwd: PKG_DIR })
28
28
  }
29
29
 
30
- // 2. Install @nuxtjs/i18n
31
30
  console.log('\n📥 Installing @nuxtjs/i18n...')
32
31
  run('npm install @nuxtjs/i18n@latest', { cwd: TARGET_DIR })
33
32
 
34
- // 3. Link local @uipkge/nuxt only if not already installed
35
33
  if (!isInstalled) {
36
- console.log('\n🔗 Linking @uipkge/nuxt...')
37
34
  run('npm link', { cwd: PKG_DIR })
38
35
  run('npm link @uipkge/nuxt', { cwd: TARGET_DIR })
39
36
  }
40
37
 
41
- // 4. Create i18n folder structure (inside app/ for Nuxt 4 compatibility)
42
- const i18nDir = path.join(TARGET_DIR, 'app/i18n/locales')
43
- if (!fs.existsSync(i18nDir)) {
44
- console.log('\n📁 Creating i18n folders...')
45
- fs.mkdirSync(i18nDir, { recursive: true })
46
- }
47
-
48
- // 5. Create i18n.config.ts
49
- const i18nConfigPath = path.join(TARGET_DIR, 'app/i18n/i18n.config.ts')
50
- if (!exists('app/i18n/i18n.config.ts')) {
51
- console.log('📝 Creating i18n.config.ts...')
52
- fs.writeFileSync(i18nConfigPath, `export default defineI18nConfig(() => ({
53
- numberFormats: {
54
- en: { currency: { style: 'currency', currency: 'USD' } },
55
- es: { currency: { style: 'currency', currency: 'EUR' } },
56
- fr: { currency: { style: 'currency', currency: 'EUR' } },
57
- ar: { currency: { style: 'currency', currency: 'SAR' } },
58
- he: { currency: { style: 'currency', currency: 'ILS' } },
59
- de: { currency: { style: 'currency', currency: 'EUR' } },
60
- },
61
- datetimeFormats: {
62
- en: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
63
- es: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
64
- fr: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
65
- ar: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
66
- he: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
67
- de: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
68
- },
69
- }))
70
- `)
71
- }
72
-
73
- // 6. Create locale files
74
- const locales = {
75
- en: { nav_features: 'Features', nav_docs: 'Docs', nav_pricing: 'Pricing', hero_title: 'Translate faster, ship with confidence', hero_subtitle: 'i18now keeps your translations in sync as you code.', footer_tagline: 'Built for developers who ship fast.' },
76
- es: { nav_features: 'Características', nav_docs: 'Docs', nav_pricing: 'Precios', hero_title: 'Traduce más rápido, envía con confianza', hero_subtitle: 'i18now mantiene tus traducciones sincronizadas.', footer_tagline: 'Construido para desarrolladores rápidos.' },
77
- }
78
- for (const [code, messages] of Object.entries(locales)) {
79
- const localePath = path.join(i18nDir, `${code}.json`)
80
- if (!fs.existsSync(localePath)) {
81
- const data = {
82
- nav: { features: messages.nav_features, docs: messages.nav_docs, pricing: messages.nav_pricing },
83
- hero: { title: messages.hero_title, subtitle: messages.hero_subtitle },
84
- footer: { tagline: messages.footer_tagline }
85
- }
86
- fs.writeFileSync(localePath, JSON.stringify(data, null, 2))
87
- }
88
- }
89
-
90
- // 7. Update nuxt.config.ts
91
38
  const nuxtConfigPath = path.join(TARGET_DIR, 'nuxt.config.ts')
92
- console.log('\n⚙️ Updating nuxt.config.ts...')
93
39
  const nuxtConfigContent = `export default defineNuxtConfig({
94
40
  compatibilityDate: '2025-07-15',
95
41
  devtools: { enabled: true },
96
42
  modules: ['@nuxtjs/i18n', '@uipkge/nuxt'],
97
43
  i18n: {
98
44
  defaultLocale: 'en',
99
- locales: [
100
- { code: 'en', file: 'en.json' },
101
- { code: 'es', file: 'es.json' },
102
- { code: 'fr', file: 'fr.json' },
103
- { code: 'ar', file: 'ar.json' },
104
- { code: 'he', file: 'he.json' },
105
- { code: 'de', file: 'de.json' },
106
- ],
107
- langDir: 'locales/',
108
- strategy: 'no_prefix',
109
- detectBrowserLanguage: { useCookie: true, cookieKey: 'i18n_locale' },
110
- vueI18n: './i18n/i18n.config.ts',
111
45
  },
112
46
  i18now: {
113
47
  projectId: process.env.I18NOW_PROJECT_ID ?? '',
114
48
  apiKey: process.env.I18NOW_API_KEY ?? '',
115
- host: process.env.I18NOW_HOST ?? 'https://i18now.com',
116
- cdnUrl: process.env.I18NOW_CDN_URL ?? 'https://cdn.i18now.com',
117
- environment: process.env.I18NOW_ENV ?? 'dev',
118
- syncIn: ['development'],
119
49
  },
120
50
  })
121
51
  `
122
52
  fs.writeFileSync(nuxtConfigPath, nuxtConfigContent)
123
53
 
124
- // 8. Create test page
125
54
  const pagesDir = path.join(TARGET_DIR, 'app/pages')
126
55
  if (!fs.existsSync(pagesDir)) {
127
56
  fs.mkdirSync(pagesDir, { recursive: true })
@@ -129,41 +58,20 @@ if (!fs.existsSync(pagesDir)) {
129
58
 
130
59
  const indexPagePath = path.join(pagesDir, 'index.vue')
131
60
  if (!fs.existsSync(indexPagePath)) {
132
- console.log('📄 Creating test page...')
133
61
  fs.writeFileSync(indexPagePath, `<script setup>
134
- const { t, locale, setLocale, te, n, d } = useI18now()
135
-
136
- const locales = [
137
- { code: 'en', label: 'English', flag: '🇬🇧' },
138
- { code: 'es', label: 'Español', flag: '🇪🇸' },
139
- { code: 'fr', label: 'Français', flag: '🇫🇷' },
140
- { code: 'ar', label: 'العربية', flag: '🇸🇦' },
141
- { code: 'he', label: 'עברית', flag: '🇮🇱' },
142
- { code: 'de', label: 'Deutsch', flag: '🇩🇪' },
143
- ]
144
-
145
- const dir = computed(() => {
146
- try {
147
- return new Intl.Locale(locale.value).textInfo?.direction ?? 'ltr'
148
- } catch {
149
- return 'ltr'
150
- }
151
- })
62
+ const { t, locale } = useI18now()
152
63
  </script>
153
64
 
154
65
  <template>
155
- <div :dir="dir">
156
- <h1>{{ t('hero.title', 'Hello World') }}</h1>
157
- <p>{{ t('hero.subtitle', 'Welcome to i18now') }}</p>
66
+ <div>
67
+ <h1>{{ t('hello', 'Hello World') }}</h1>
158
68
  <select v-model="locale">
159
- <option v-for="l in locales" :key="l.code" :value="l.code">
160
- {{ l.flag }} {{ l.label }}
161
- </option>
69
+ <option value="en">English</option>
70
+ <option value="es">Español</option>
162
71
  </select>
163
72
  </div>
164
73
  </template>
165
74
  `)
166
75
  }
167
76
 
168
- console.log('\n✅ Setup complete!')
169
- console.log('Run: npm run dev\n')
77
+ console.log('\n✅ Ready! Run: npm run dev\n')
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.1.25",
7
+ "version": "0.1.30",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipkge/nuxt",
3
- "version": "0.1.25",
3
+ "version": "0.1.30",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {