next-i18n-lite 2.0.1 → 2.1.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 CHANGED
@@ -27,8 +27,11 @@ pnpm add next-i18n-lite
27
27
  ```
28
28
 
29
29
  ## Scaffold Prompt
30
-
30
+ ```bash
31
+ npx setup-i18n
32
+ ```
31
33
  When you install the library, you will see a prompt like this in your terminal:
34
+
32
35
  ⚡ **Prompt:** Do you want to auto-configure the i18n library using scaffold? (Y/n)
33
36
 
34
37
  ✅ Press Enter (default) → scaffold runs
@@ -90,7 +93,7 @@ app/
90
93
  ```
91
94
  ### 1. Create translation files
92
95
 
93
- ```bash
96
+ ```ts
94
97
  // lib/locales/en.ts
95
98
  export const en = {
96
99
  home:'Home',
@@ -104,7 +107,7 @@ export const en = {
104
107
  },
105
108
  };
106
109
  ```
107
- ```bash
110
+ ```ts
108
111
  // lib/locales/es.ts
109
112
  export const es = {
110
113
  home:'Home',
@@ -118,7 +121,7 @@ export const es = {
118
121
  },
119
122
  };
120
123
  ```
121
- ```bash
124
+ ```ts
122
125
  // lib/locales/fr.ts
123
126
  export const fr = {
124
127
  common: {
@@ -131,7 +134,7 @@ export const fr = {
131
134
  },
132
135
  };
133
136
  ```
134
- ```bash
137
+ ```ts
135
138
  // lib/locales/pt.ts
136
139
  export const pt = {
137
140
  common: {
@@ -144,7 +147,7 @@ export const pt = {
144
147
  },
145
148
  };
146
149
  ```
147
- ```bash
150
+ ```ts
148
151
  // lib/locales/de.ts
149
152
  export const de = {
150
153
  common: {
@@ -158,7 +161,7 @@ export const de = {
158
161
  };
159
162
  ```
160
163
 
161
- ```bash
164
+ ```ts
162
165
  // lib/locales/ar.ts
163
166
  export const ar = {
164
167
  common: {
@@ -175,7 +178,7 @@ export const ar = {
175
178
  ### 2. Setup Provider (Next.js App Router)
176
179
 
177
180
  #### I18nBoundary.tsx
178
- ```bash
181
+ ```ts
179
182
  // app/lib/I18nBoundary.tsx
180
183
  'use client';
181
184
  import { ReactNode, useEffect, useState } from 'react';
@@ -227,11 +230,11 @@ still may face issue for setLocale
227
230
 
228
231
  Fix: not actually fixed yet but if you don't like red flags in code just
229
232
 
230
- ```bash
233
+ ```ts
231
234
  // eslint-disable-next-line react-hooks/set-state-in-effect
232
235
  ```
233
236
  yup! ignore it :D
234
- ```bash
237
+ ```ts
235
238
  // app/layout.tsx
236
239
  import { I18nBoundary } from "./lib/I18nBoundary";
237
240
 
@@ -254,7 +257,7 @@ also i provided 2 options:
254
257
  - Choice 2:Hover dropdown list
255
258
 
256
259
  you can ignore styling & lucide-react library both only for example ^^
257
- ```bash
260
+ ```ts
258
261
  // components/i18n/LocaleSwitcher.tsx
259
262
  'use client';
260
263
 
@@ -320,7 +323,7 @@ Returns:
320
323
  - `locale` - Current locale
321
324
  - `setLocale(locale)` - Change locale
322
325
  - `isRTL` - Boolean indicating RTL direction
323
- ```bash
326
+ ```ts
324
327
  'use client';
325
328
  import { useI18n } from "next-i18n-lite/react";
326
329
 
@@ -352,7 +355,7 @@ library also provides helper function to
352
355
  according to the current locale.
353
356
  ---
354
357
 
355
- ```bash
358
+ ```ts
356
359
  import { pluralize } from "next-i18n-lite"
357
360
  export default function Cart() {
358
361
  const { t } = useI18n();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-i18n-lite",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Lightweight i18n library for Next.js with TypeScript support",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -26,12 +26,12 @@
26
26
  "scripts": {
27
27
  "build": "tsup",
28
28
  "dev": "tsup --watch",
29
- "postinstall": "node ./scripts/postinstall.mjs || true",
29
+ "postinstall": "node -e \"console.log('✨ next-i18n-lite installed! Run: npx setup-i18n')\"",
30
30
  "prepublishOnly": "npm run build",
31
31
  "test": "echo \"Error: no test specified\" && exit 1"
32
32
  },
33
- "bin":{
34
- "setup-i18n": "./scripts/scaffoldI18n.mjs"
33
+ "bin": {
34
+ "setup-i18n": "./scripts/setup-i18n.mjs"
35
35
  },
36
36
  "keywords": [
37
37
  "i18n",
@@ -7,18 +7,20 @@ const rl = readline.createInterface({
7
7
  output: process.stdout,
8
8
  });
9
9
 
10
- // Default answer is Yes (y) → user must type 'N' to skip
10
+ // Default = YES → user must type N
11
11
  rl.question(
12
- 'Do you want to auto-configure the i18n library using scaffold? (Y/n) ',
12
+ '🌍 Do you want to auto-configure the i18n library using scaffold? (Y/n) ',
13
13
  (answer) => {
14
14
  const normalized = answer.trim().toLowerCase();
15
+
15
16
  if (normalized === 'n') {
16
- console.log('Skipped scaffold.');
17
+ console.log('⏭️ Scaffold skipped.');
17
18
  } else {
18
- console.log('Running scaffold...');
19
+ console.log('⚙️ Running scaffold...');
19
20
  scaffoldI18n();
20
21
  console.log('✅ Scaffold completed!');
21
22
  }
23
+
22
24
  rl.close();
23
25
  }
24
26
  );