Skip to content

Commit 8835f90

Browse files
authored
feat: Support for keyPrefix in some libraries (#24)
1 parent 6b41def commit 8835f90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1161
-475
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.tests
2+
.tmp_projects
23
.repro*
34

45
demo/*.mp4
6+
demo/*.png
57

68
node_modules
79
package-lock.json

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ clean-test:
99
@echo "Cleaning up test files..."
1010
rm -rf .tests
1111
rm -rf tests/.tmp_projects
12+
13+
.PHONY: format
14+
format:
15+
@echo "Formatting files..."
16+
stylua -g '*.lua' .

README-ja.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@
77
[![GitHub Release](https://img.shields.io/github/release/nabekou29/js-i18n.nvim?style=flat)](https://github.com/nabekou29/js-i18n.nvim/releases/latest)
88
[![tests](https://github.com/nabekou29/js-i18n.nvim/actions/workflows/test.yaml/badge.svg)](https://github.com/nabekou29/js-i18n.nvim/actions/workflows/test.yaml)
99

10-
js-i18n.nvim は、JavaScript のライブラリである i18next のための Neovim プラグインです。
10+
js-i18n.nvim は、JavaScript の i18n ライブラリをサポートする Neovim プラグインです。
1111

1212
<div>
1313
<video src="https://github.com/user-attachments/assets/abcd728d-42d1-46d2-8d18-072102b1cf71" type="video/mp4" />
1414
</div>
1515

16+
## 🚧 ステータス
17+
18+
> [!WARNING]
19+
> このプラグインはまだ開発中であり、開発者の利用ケースに最適化しています。
20+
1621
## ✨ 機能
1722

1823
- 翻訳をバーチャルテキストとして表示
@@ -22,11 +27,17 @@ js-i18n.nvim は、JavaScript のライブラリである i18next のための N
2227
- ホバーによる翻訳の表示
2328
- キーの補完
2429
- モノレポ のサポート
30+
- いくつかのライブラリのサポート (i18next, react-i18next, next-intl)
2531

26-
## 🚧 ステータス
32+
### サポートしているライブラリ
2733

28-
> [!WARNING]
29-
> このプラグインはまだ開発中であり、開発者の利用ケースに最適化しています。
34+
#### [i18next](https://www.i18next.com/), [react-i18next](https://react.i18next.com/)
35+
36+
![i18next-screenshot](https://github.com/user-attachments/assets/349f5242-f717-4af9-9790-623ddad0492f)
37+
38+
#### [next-intl](https://next-intl-docs.vercel.app/)
39+
40+
![next-intl-screenshot](https://github.com/user-attachments/assets/e6873336-5161-40b1-9bcc-c845ca750860)
3041

3142
## ✅ 必須条件
3243

@@ -100,10 +111,6 @@ js-i18n.nvim は、JavaScript のライブラリである i18next のための N
100111

101112
## ⬆️ ロードマップ
102113

103-
今後もいくつかの機能の追加を予定しています。
104-
105-
- i18next のサポートの強化
106-
- react-i18next や、i18next の高度な利用についてもサポートする予定です。
107-
- `namespace``keyPrefix` のサポート
108-
- `Trans` コンポーネントのサポート
109-
- i18next 以外のライブラリのサポート
114+
- ライブラリサポートの強化
115+
- namespace のサポート
116+
- 今より賢い翻訳リソースの検出

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ _⚠︎ This file is translated and updated by ChatGPT based on the original tex
1313
[![GitHub Release](https://img.shields.io/github/release/nabekou29/js-i18n.nvim?style=flat)](https://github.com/nabekou29/js-i18n.nvim/releases/latest)
1414
[![tests](https://github.com/nabekou29/js-i18n.nvim/actions/workflows/test.yaml/badge.svg)](https://github.com/nabekou29/js-i18n.nvim/actions/workflows/test.yaml)
1515

16-
js-i18n.nvim is a Neovim plugin for the JavaScript library i18next.
16+
js-i18n.nvim is a Neovim plugin that supports JavaScript i18n libraries.
1717

1818
<div>
1919
<video src="https://github.com/user-attachments/assets/abcd728d-42d1-46d2-8d18-072102b1cf71" type="video/mp4" />
2020
</div>
2121

22+
## 🚧 Status
23+
24+
> [!WARNING]
25+
> This plugin is still under development and is optimized for the developer's use cases.
26+
2227
## ✨ Features
2328

2429
- Display translations as virtual text
@@ -28,11 +33,17 @@ js-i18n.nvim is a Neovim plugin for the JavaScript library i18next.
2833
- Display translations for each language on hover
2934
- Key completion
3035
- Support for monorepos
36+
- Support for multiple libraries (i18next, react-i18next, next-intl)
3137

32-
## 🚧 Status
38+
### Supported Libraries
3339

34-
> [!WARNING]
35-
> This plugin is still under development and is optimized for the developer's use cases.
40+
#### [i18next](https://www.i18next.com/), [react-i18next](https://react.i18next.com/)
41+
42+
![i18next-screenshot](https://github.com/user-attachments/assets/349f5242-f717-4af9-9790-623ddad0492f)
43+
44+
#### [next-intl](https://next-intl-docs.vercel.app/)
45+
46+
![next-intl-screenshot](https://github.com/user-attachments/assets/e6873336-5161-40b1-9bcc-c845ca750860)
3647

3748
## ✅ Requirements
3849

@@ -105,10 +116,6 @@ The default settings are as follows. For omitted parts, refer to [config.lua](./
105116

106117
## ⬆️ Roadmap
107118

108-
We plan to add several features in the future.
109-
110-
- Enhanced support for i18next
111-
- Planning to support advanced usage of i18next and react-i18next.
112-
- `namespace` and `keySeparator` options support
113-
- `Trans` component support
114-
- Support for libraries other than i18next
119+
- Enhanced support for libraries
120+
- Namespace support
121+
- Smarter translation resource detection

demo/concept.tape

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Set TypingSpeed 0.2
1111

1212
Hide
1313

14-
Type@0 "nvim -u config.lua projects/i18next/index.jsx" Enter
14+
Type@0 "nvim -u config.lua projects/i18next/concept.jsx" Enter
1515

1616
Sleep 5 # load lazy.nvim
1717
# Type q # lazy.nvim がエラーになるので閉じる
File renamed without changes.

demo/projects/i18next/locales/en/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"part-1": "This is a demo of js-i18next.nvim .",
55
"part-2": "You can check the text in each language by hovering.",
66
"part-3": "You can also use the completion."
7+
},
8+
"key": "Key",
9+
"nested": {
10+
"key": "Nested Key"
711
}
812
}

demo/projects/i18next/locales/ja/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"part-1": "これは js-i18next.nvim のデモです。",
55
"part-2": "ホバーで各言語の文言を確認できます。",
66
"part-3": "補完機能も使えます。"
7+
},
8+
"key": "Key",
9+
"nested": {
10+
"key": "Nested Key"
711
}
812
}

demo/projects/i18next/screenshot.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { useTranslation } from "react-i18next";
2+
3+
export const Component1 = () => {
4+
const { t } = useTranslation();
5+
6+
return (
7+
<div>
8+
<p>{t("key")}</p>
9+
<p>{t("nested.key")}</p>
10+
<Trans i18nKey={"key"} t={t} />
11+
</div>
12+
);
13+
};
14+
15+
export const Component2 = () => {
16+
const { t } = useTranslation("translation", { keyPrefix: "nested" });
17+
18+
return (
19+
<div>
20+
<p>{t("key")}</p>
21+
</div>
22+
);
23+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"nested": {
3+
"key": "Nested Key"
4+
},
5+
"key": "Key",
6+
"rich-key": "<highlight>Rich Key</highlight>"
7+
}

0 commit comments

Comments
 (0)