Commit 56fef8b
Changed files (26)
packages
i18n
src
src
i18n/en/cli/index.ts → packages/i18n/src/en/cli/index.ts
File renamed without changes
i18n/en/web/index.ts → packages/i18n/src/en/web/index.ts
File renamed without changes
i18n/en/index.ts → packages/i18n/src/en/index.ts
File renamed without changes
i18n/zh-CN/cli/index.ts → packages/i18n/src/zh-CN/cli/index.ts
File renamed without changes
i18n/zh-CN/web/index.ts → packages/i18n/src/zh-CN/web/index.ts
File renamed without changes
i18n/zh-CN/index.ts → packages/i18n/src/zh-CN/index.ts
File renamed without changes
i18n/zh-TW/cli/index.ts → packages/i18n/src/zh-TW/cli/index.ts
File renamed without changes
i18n/zh-TW/web/index.ts → packages/i18n/src/zh-TW/web/index.ts
File renamed without changes
i18n/zh-TW/index.ts → packages/i18n/src/zh-TW/index.ts
File renamed without changes
i18n/custom-types.ts → packages/i18n/src/custom-types.ts
File renamed without changes
i18n/formatters.ts → packages/i18n/src/formatters.ts
File renamed without changes
i18n/i18n-node.ts → packages/i18n/src/i18n-node.ts
File renamed without changes
i18n/i18n-types.ts → packages/i18n/src/i18n-types.ts
File renamed without changes
i18n/i18n-util.async.ts → packages/i18n/src/i18n-util.async.ts
File renamed without changes
i18n/i18n-util.sync.ts → packages/i18n/src/i18n-util.sync.ts
File renamed without changes
i18n/i18n-util.ts → packages/i18n/src/i18n-util.ts
File renamed without changes
packages/i18n/src/index.ts
@@ -0,0 +1,2 @@
+export type { Locales } from './i18n-types';
+export { L } from './i18n-node';
.typesafe-i18n.json → packages/i18n/.typesafe-i18n.json
@@ -3,5 +3,5 @@
"baseLocale": "en",
"adapter": "node",
"esmImports": true,
- "outputPath": "./i18n/"
+ "outputPath": "./src/"
}
packages/i18n/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "@astral-halo/i18n",
+ "scripts": {
+ "typesafe-i18n": "typesafe-i18n"
+ },
+ "main": "src/index.ts",
+ "dependencies": {
+ "typesafe-i18n": "^5.26.2"
+ }
+}
scripts/new.ts
@@ -1,8 +1,7 @@
-import L from '../i18n/i18n-node';
-import type { Locales } from '../i18n/i18n-types';
import { config as scriptConfig } from './config';
import { changeFrontmatter, findAvailableFileName, slugify } from './utils';
import type { AvailableFileNameInfo } from './utils';
+import { L, type Locales } from '@astral-halo/i18n';
import { Command, OptionValues } from '@commander-js/extra-typings';
import { ExitPromptError } from '@inquirer/core';
import { input, select } from '@inquirer/prompts';
scripts/pub.ts
@@ -1,8 +1,7 @@
-import L from '../i18n/i18n-node';
-import type { Locales } from '../i18n/i18n-types';
import { config as scriptConfig } from './config';
import { findAvailableFileName, slugify } from './utils';
import type { AvailableFileNameInfo } from './utils';
+import { L, type Locales } from '@astral-halo/i18n';
import { ExitPromptError } from '@inquirer/core';
import { input, select } from '@inquirer/prompts';
import dayjs from 'dayjs';
src/types/config.d.ts
@@ -1,4 +1,4 @@
-import type { Locales } from 'i18n/i18n-types';
+import type { Locales } from '@astral-halo/i18n';
// ============================================================================
export type Favicon = {
src/utils/i18n.ts
@@ -1,4 +1,4 @@
-import originalL from '../../i18n/i18n-node';
import { siteConfig } from '../config';
+import { L } from '@astral-halo/i18n';
-export const t = originalL[siteConfig.lang].web;
+export const t = L[siteConfig.lang].web;
src/config.ts
@@ -1,7 +1,6 @@
// WARNING: This file will be bundled into the build product.
// DO NOT add any sensitive information here.
// 警告: 该文件会被打包到构建产物中, 不要在此添加任何敏感信息
-import L from '../i18n/i18n-node';
import type {
ArticleConfig,
AsideConfig,
@@ -16,6 +15,7 @@ import type {
SiteConfig,
ToolBarConfig,
} from './types/config';
+import { L } from '@astral-halo/i18n';
export const siteConfig: SiteConfig = {
title: 'Astral Halo',
package.json
@@ -7,13 +7,13 @@
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
- "typesafe-i18n": "typesafe-i18n",
"lint": "eslint ./src --fix && stylelint ./src/**/*.{scss,css,astro} --fix && astro check",
"format": "prettier --write ./src",
"new": "tsx scripts/new.ts",
"pub": "tsx scripts/pub.ts"
},
"dependencies": {
+ "@astral-halo/i18n": "workspace:*",
"@astrojs/markdown-remark": "^6.3.1",
"@astrojs/mdx": "^4.2.6",
"@astrojs/rss": "^4.0.11",
@@ -101,7 +101,6 @@
"stylelint": "^16.19.1",
"stylelint-config-html": "^1.1.0",
"tsx": "^4.19.4",
- "typesafe-i18n": "^5.26.2",
"typescript-eslint": "^8.32.1"
},
"pnpm": {
pnpm-workspace.yaml
@@ -0,0 +1,2 @@
+packages:
+ - 'packages/**/*'