@zachhandley/ez-i18n 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # ez-i18n
1
+ # @zachhandley/ez-i18n
2
2
 
3
3
  Cookie-based i18n for Astro + Vue. No URL prefixes, reactive language switching.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pnpm add ez-i18n nanostores @nanostores/persistent
8
+ pnpm add @zachhandley/ez-i18n nanostores @nanostores/persistent
9
9
  # If using Vue:
10
10
  pnpm add @nanostores/vue
11
11
  ```
@@ -18,7 +18,7 @@ pnpm add @nanostores/vue
18
18
  // astro.config.ts
19
19
  import { defineConfig } from 'astro/config';
20
20
  import vue from '@astrojs/vue';
21
- import ezI18n from 'ez-i18n';
21
+ import ezI18n from '@zachhandley/ez-i18n';
22
22
 
23
23
  export default defineConfig({
24
24
  integrations: [
@@ -28,9 +28,9 @@ export default defineConfig({
28
28
  defaultLocale: 'en',
29
29
  cookieName: 'my-locale', // optional, defaults to 'ez-locale'
30
30
  translations: {
31
- en: './src/i18n/en.ts',
32
- es: './src/i18n/es.ts',
33
- fr: './src/i18n/fr.ts',
31
+ en: './src/i18n/en.json',
32
+ es: './src/i18n/es.json',
33
+ fr: './src/i18n/fr.json',
34
34
  },
35
35
  }),
36
36
  ],
@@ -39,21 +39,22 @@ export default defineConfig({
39
39
 
40
40
  ### Translation Files
41
41
 
42
- ```typescript
43
- // src/i18n/en.ts
44
- export default {
45
- common: {
46
- welcome: 'Welcome',
47
- save: 'Save',
48
- cancel: 'Cancel',
49
- },
50
- auth: {
51
- login: 'Log in',
52
- signup: 'Sign up',
42
+ ```json
43
+ {
44
+ "common": {
45
+ "welcome": "Welcome",
46
+ "save": "Save",
47
+ "cancel": "Cancel"
53
48
  },
54
- };
49
+ "auth": {
50
+ "login": "Log in",
51
+ "signup": "Sign up"
52
+ }
53
+ }
55
54
  ```
56
55
 
56
+ Create similar files for each locale: `src/i18n/en.json`, `src/i18n/es.json`, etc.
57
+
57
58
  ### Layout Setup
58
59
 
59
60
  Add the `EzI18nHead` component to your layout's head for automatic hydration:
@@ -61,7 +62,7 @@ Add the `EzI18nHead` component to your layout's head for automatic hydration:
61
62
  ```astro
62
63
  ---
63
64
  // src/layouts/Layout.astro
64
- import { EzI18nHead } from 'ez-i18n/astro';
65
+ import { EzI18nHead } from '@zachhandley/ez-i18n/astro';
65
66
  const { locale, translations } = Astro.locals;
66
67
  ---
67
68
 
@@ -93,7 +94,7 @@ const { locale, translations } = Astro.locals;
93
94
 
94
95
  ```vue
95
96
  <script setup lang="ts">
96
- import { useI18n } from 'ez-i18n/vue';
97
+ import { useI18n } from '@zachhandley/ez-i18n/vue';
97
98
  import { translationLoaders } from 'ez-i18n:translations';
98
99
 
99
100
  const { t, locale, setLocale } = useI18n();
@@ -126,7 +127,7 @@ Register the Vue plugin in your entrypoint:
126
127
  ```typescript
127
128
  // src/_vueEntrypoint.ts
128
129
  import type { App } from 'vue';
129
- import { ezI18nVue } from 'ez-i18n/vue';
130
+ import { ezI18nVue } from '@zachhandley/ez-i18n/vue';
130
131
 
131
132
  export default (app: App) => {
132
133
  app.use(ezI18nVue);
@@ -9,7 +9,7 @@ import 'nanostores';
9
9
  *
10
10
  * @example
11
11
  * // In _vueEntrypoint.ts or main.ts
12
- * import { ezI18nVue } from 'ez-i18n/vue';
12
+ * import { ezI18nVue } from '@zachhandley/ez-i18n/vue';
13
13
  *
14
14
  * export default (app) => {
15
15
  * app.use(ezI18nVue);
@@ -29,7 +29,7 @@ declare const ezI18nVue: Plugin;
29
29
  *
30
30
  * @example
31
31
  * <script setup>
32
- * import { useI18n } from 'ez-i18n/vue';
32
+ * import { useI18n } from '@zachhandley/ez-i18n/vue';
33
33
  *
34
34
  * const { t, locale, setLocale } = useI18n();
35
35
  * const greeting = t('welcome.greeting');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zachhandley/ez-i18n",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -60,7 +60,7 @@ function createTranslateFunction(
60
60
  *
61
61
  * @example
62
62
  * // In _vueEntrypoint.ts or main.ts
63
- * import { ezI18nVue } from 'ez-i18n/vue';
63
+ * import { ezI18nVue } from '@zachhandley/ez-i18n/vue';
64
64
  *
65
65
  * export default (app) => {
66
66
  * app.use(ezI18nVue);
@@ -105,7 +105,7 @@ export const ezI18nVue: Plugin = {
105
105
  *
106
106
  * @example
107
107
  * <script setup>
108
- * import { useI18n } from 'ez-i18n/vue';
108
+ * import { useI18n } from '@zachhandley/ez-i18n/vue';
109
109
  *
110
110
  * const { t, locale, setLocale } = useI18n();
111
111
  * const greeting = t('welcome.greeting');