i18nya 0.2.4 → 0.2.5

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
@@ -7,7 +7,7 @@ Its tiny footprint and simple API make it perfect for projects that want localiz
7
7
 
8
8
  - 🐾 **Tiny**: Less than 100 lines of TypeScript, 0 dependencies.
9
9
  - ⏬️ **Flexible fallback**: Supports fallback languages out of the box.
10
- - 🧩 **Extensible**: Can be easily extended to integrate into other frameworks (e.g. `astro-i18nya`).
10
+ - 🧩 **Extensible**: Can be easily extended to integrate into other frameworks (e.g. [`astro-i18nya`](https://www.npmjs.com/package/astro-i18nya)).
11
11
  - 🔨 **Typed**: Optional translation key completions for `t()`.
12
12
 
13
13
  ## Installation
@@ -37,12 +37,13 @@ const i18nya = await init({
37
37
  langDir: "../langs", // only this is required
38
38
  defaultLang: "en",
39
39
  fallbackLangs: {
40
- // all languages fallback to English, specify special fallbacks here
40
+ // all languages fallback to defaultLang, specify special fallbacks here
41
41
  zh_HK: "zh_TW",
42
42
  },
43
43
  // if you use vite, you need to import manually using this:
44
44
  viteImports: import.meta.glob("../langs/*.json", { eager: true }),
45
- // otherwise, i18nya will search & import the json files using node modules (which vite does not ship)
45
+ // otherwise, i18nya will search & import the json files using node modules
46
+ // (which vite does not ship)
46
47
  });
47
48
 
48
49
  export default i18nya;
package/jest.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Config } from 'jest';
2
+
3
+ const config: Config = {
4
+ preset: "ts-jest",
5
+ "testPathIgnorePatterns": [
6
+ "<rootDir>/astro-i18nya",
7
+ "<rootDir>/dist"
8
+ ],
9
+ transform: {
10
+ '^.+\\.(ts|tsx)$': 'ts-jest',
11
+ },
12
+ };
13
+
14
+ export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18nya",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "i18n as small as a cat's paw",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -27,20 +27,11 @@
27
27
  "url": "https://github.com/FyraLabs/i18nya/issues"
28
28
  },
29
29
  "homepage": "https://github.com/FyraLabs/i18nya#readme",
30
- "jest": {
31
- "testPathIgnorePatterns": [
32
- "<rootDir>/astro-i18nya",
33
- "<rootDir>/dist"
34
- ]
35
- },
36
30
  "devDependencies": {
37
- "@babel/core": "^7.28.5",
38
- "@babel/preset-env": "^7.28.5",
39
- "@babel/preset-typescript": "^7.28.5",
40
31
  "@types/jest": "^30.0.0",
41
32
  "@types/node": "^24.10.1",
42
- "babel-jest": "^30.2.0",
43
33
  "jest": "^30.2.0",
34
+ "ts-jest": "^29.4.9",
44
35
  "typescript": "^5.9.3"
45
36
  }
46
37
  }
@@ -1,63 +0,0 @@
1
- # astro-i18nya
2
-
3
- I18n support for astro.
4
-
5
- ## Features
6
-
7
- - Integration with `i18nya` and `astro`
8
- - A `<Trans />` component that works better than the one in `react-i18next`!
9
-
10
- ## Installation
11
-
12
- ```sh
13
- npx astro add astro-i18nya
14
- # or
15
- npm install astro-i18nya
16
- ```
17
-
18
- Make sure you called `init()` from `i18nya` in `src/i18n.ts`:
19
-
20
- ```ts
21
- import { init } from 'i18nya';
22
-
23
- const i18nya = await init({ ... });
24
- export default i18nya;
25
- ```
26
-
27
- Then in `astro.config.mjs`:
28
-
29
- ```ts
30
- import i18nya from "./src/i18n";
31
- import astro_i18nya from "astro-i18nya";
32
-
33
- export default defineConfig({
34
- integrations: [astro_i18nya(i18nya)],
35
- // `i18n:` is not needed
36
- });
37
- ```
38
-
39
- Then for all pages in `src/pages/[...lang]/*.astro`:
40
-
41
- ```ts
42
- import i18nya, { makeT } from "../../i18n.ts";
43
- import { makeGetStaticPaths } from "astro-i18nya";
44
- const t = makeT(Astro.params.lang);
45
- // generate paths only for languages in your `[...langs]/` folder!
46
- export const getStaticPaths = makeGetStaticPaths(i18nya);
47
- ```
48
-
49
- ## Trans
50
-
51
- ```tsx
52
- <Trans t={t("test", { user: "John" })}>
53
- <b />
54
- <a href="https://example.com" />
55
- </Trans>
56
- ```
57
-
58
- With `"test": "Hello <1>{{user}}</1>, welcome to <2><1>my site</1></2>."`, the above element will become:
59
-
60
- ```html
61
- <b>Hello John</b>, welcome to <a href="https://example.com"><b>my site</b></a
62
- >.
63
- ```
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- ['@babel/preset-env', {targets: {node: 'current'}}],
4
- '@babel/preset-typescript',
5
-
6
- ['@babel/preset-react', {runtime: 'automatic'}],
7
- ],
8
- };
@@ -1,7 +0,0 @@
1
- import type {Config} from 'jest';
2
-
3
- const config: Config = {
4
- "testEnvironment": "jsdom"
5
- };
6
-
7
- export default config;