Skip to content

Commit f05f494

Browse files
committed
add i18n
1 parent 14a8d8e commit f05f494

9 files changed

+53
-4
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# An array of strings which contain Language Ids defined by VS Code
2+
# You can check available language ids here: https://code.visualstudio.com/docs/languages/identifiers
3+
languageIds:
4+
- typescript
5+
6+
# Look for t("...")
7+
usageMatchRegex:
8+
- "[^\\w\\d]t\\(['\"`]({key})['\"`]"
9+
10+
# Disable other built-in i18n ally frameworks
11+
monopoly: true

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
/* i18n-ally */
3+
"i18n-ally.localesPaths": ["src/locales"],
4+
"i18n-ally.keystyle": "nested",
5+
6+
/* antfu's eslint */
27
// Enable the ESlint flat config support
38
"eslint.experimental.useFlatConfig": true,
49

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"type": "module",
44
"version": "0.0.0",
55
"private": true,
6-
"description": "manifest.json description",
76
"scripts": {
87
"dev": "wxt",
98
"dev:firefox": "wxt -b firefox",
@@ -20,6 +19,7 @@
2019
"dependencies": {
2120
"@radix-ui/react-icons": "^1.3.0",
2221
"@radix-ui/react-slot": "^1.1.0",
22+
"@wxt-dev/i18n": "^0.1.0",
2323
"class-variance-authority": "^0.7.0",
2424
"clsx": "^2.1.1",
2525
"react": "^18.3.1",

pnpm-lock.yaml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/entrypoints/background.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default defineBackground(() => {
22
// eslint-disable-next-line no-console
3-
console.log('Hello background!', { id: browser.runtime.id })
3+
console.log(`${i18n.t('hello')} background!`, { id: browser.runtime.id })
44
})

src/entrypoints/popup/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Button } from '@/components/ui/button'
33
function App() {
44
return (
55
<>
6-
<Button>popup</Button>
6+
<Button>{`${i18n.t('hello')} popup`}</Button>
77
</>
88
)
99
}

src/locales/en.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extension:
2+
name: wxt-starter
3+
description: https://github.com/mefengl/wxt-starter
4+
hello: Hello

src/locales/zh.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extension:
2+
name: wxt-starter
3+
description: https://github.com/mefengl/wxt-starter
4+
hello: 你好

wxt.config.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { defineConfig } from 'wxt'
33
// See https://wxt.dev/api/config.html
44
export default defineConfig({
55
manifest: {
6+
default_locale: 'en',
7+
description: '__MSG_extension_description__',
8+
name: '__MSG_extension_name__',
69
permissions: [],
710
},
8-
modules: ['@wxt-dev/module-react'],
11+
modules: [
12+
'@wxt-dev/module-react',
13+
'@wxt-dev/i18n/module',
14+
],
915
srcDir: 'src',
1016
})

0 commit comments

Comments
 (0)