@uipkge/nuxt 0.1.26 → 0.1.33
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 +42 -103
- package/dist/module.json +1 -1
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -18,152 +18,91 @@ function exists(file) {
|
|
|
18
18
|
return fs.existsSync(path.join(TARGET_DIR, file))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
console.log('\n🚀
|
|
21
|
+
console.log('\n🚀 @uipkge/nuxt setup\n')
|
|
22
22
|
|
|
23
23
|
if (isInstalled) {
|
|
24
|
-
console.log('📦
|
|
24
|
+
console.log('📦 Package ready')
|
|
25
25
|
} else {
|
|
26
|
-
console.log('📦 Building
|
|
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
|
-
|
|
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
|
-
}
|
|
38
|
+
const nuxtConfigPath = path.join(TARGET_DIR, 'nuxt.config.ts')
|
|
47
39
|
|
|
48
|
-
|
|
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
|
-
}
|
|
40
|
+
const { createInterface } = await import('readline')
|
|
72
41
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
42
|
+
function prompt(question) {
|
|
43
|
+
return new Promise(resolve => {
|
|
44
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
45
|
+
rl.question(question, ans => { rl.close(); resolve(ans) })
|
|
46
|
+
})
|
|
77
47
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
}
|
|
48
|
+
|
|
49
|
+
async function getInput(question, defaultValue) {
|
|
50
|
+
const answer = await prompt(question)
|
|
51
|
+
return answer.trim() || defaultValue
|
|
88
52
|
}
|
|
89
53
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
54
|
+
console.log('\n⚙️ i18now configuration:')
|
|
55
|
+
|
|
56
|
+
const projectId = await getInput('Enter projectId (or press Enter to skip): ', '')
|
|
57
|
+
const apiKey = await getInput('Enter apiKey (or press Enter to skip): ', '')
|
|
58
|
+
|
|
93
59
|
const nuxtConfigContent = `export default defineNuxtConfig({
|
|
94
60
|
compatibilityDate: '2025-07-15',
|
|
95
61
|
devtools: { enabled: true },
|
|
96
62
|
modules: ['@nuxtjs/i18n', '@uipkge/nuxt'],
|
|
97
63
|
i18n: {
|
|
98
64
|
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: 'app/i18n/locales/',
|
|
108
|
-
strategy: 'no_prefix',
|
|
109
|
-
detectBrowserLanguage: { useCookie: true, cookieKey: 'i18n_locale' },
|
|
110
|
-
vueI18n: './app/i18n/i18n.config.ts',
|
|
111
65
|
},
|
|
112
66
|
i18now: {
|
|
113
|
-
projectId:
|
|
114
|
-
apiKey:
|
|
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'],
|
|
67
|
+
projectId: '${projectId}',
|
|
68
|
+
apiKey: '${apiKey}',
|
|
119
69
|
},
|
|
120
70
|
})
|
|
121
71
|
`
|
|
122
72
|
fs.writeFileSync(nuxtConfigPath, nuxtConfigContent)
|
|
123
73
|
|
|
124
|
-
// 8. Create test page
|
|
125
74
|
const pagesDir = path.join(TARGET_DIR, 'app/pages')
|
|
126
75
|
if (!fs.existsSync(pagesDir)) {
|
|
127
76
|
fs.mkdirSync(pagesDir, { recursive: true })
|
|
128
77
|
}
|
|
129
78
|
|
|
130
|
-
const
|
|
131
|
-
if (!fs.existsSync(
|
|
132
|
-
console.log('📄 Creating test page...')
|
|
133
|
-
fs.writeFileSync(
|
|
134
|
-
const { t, locale
|
|
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
|
-
})
|
|
79
|
+
const testPagePath = path.join(TARGET_DIR, 'app/pages/i18now-test.vue')
|
|
80
|
+
if (!fs.existsSync(testPagePath)) {
|
|
81
|
+
console.log('📄 Creating test page at /i18now-test...')
|
|
82
|
+
fs.writeFileSync(testPagePath, `<script setup>
|
|
83
|
+
const { t, locale } = useI18now()
|
|
152
84
|
</script>
|
|
153
85
|
|
|
154
86
|
<template>
|
|
155
|
-
<div
|
|
156
|
-
<h1>
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
87
|
+
<div style="padding: 20px; font-family: sans-serif; max-width: 600px;">
|
|
88
|
+
<h1>i18now Test Page</h1>
|
|
89
|
+
|
|
90
|
+
<h2>Translation Keys (try adding new ones):</h2>
|
|
91
|
+
<p>{{ t('welcome_message', 'Welcome to i18now!') }}</p>
|
|
92
|
+
<p>{{ t('description', 'This is a test page for translations.') }}</p>
|
|
93
|
+
<p>{{ t('feature_sync', 'Key sync is enabled in development mode.') }}</p>
|
|
94
|
+
|
|
95
|
+
<h2>Language Switcher:</h2>
|
|
96
|
+
<select v-model="locale" style="padding: 8px; margin: 10px 0;">
|
|
97
|
+
<option value="en">English</option>
|
|
98
|
+
<option value="es">Español</option>
|
|
162
99
|
</select>
|
|
100
|
+
|
|
101
|
+
<p><small>Current locale: {{ locale }}</small></p>
|
|
102
|
+
<p><small>Add new t() calls above to test key sync!</small></p>
|
|
163
103
|
</div>
|
|
164
104
|
</template>
|
|
165
105
|
`)
|
|
166
106
|
}
|
|
167
107
|
|
|
168
|
-
console.log('\n✅
|
|
169
|
-
console.log('Run: npm run dev\n')
|
|
108
|
+
console.log('\n✅ Ready! Run: npm run dev\n')
|
package/dist/module.json
CHANGED