@arronqzy/i18n 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arronqzy/i18n",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Shared Chinese/English i18n for Abuilder (React + Vue)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,8 +31,8 @@
31
31
  "react": "^19",
32
32
  "typescript": "^5.5.4",
33
33
  "vue": "^3.5.13",
34
- "@arronqzy/typescript-config": "1.0.0",
35
- "@arronqzy/eslint-config": "0.0.0"
34
+ "@arronqzy/eslint-config": "0.0.0",
35
+ "@arronqzy/typescript-config": "1.0.0"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
@@ -128,6 +128,10 @@ export const enUS = {
128
128
  outputScale: "Output scale",
129
129
  outputScaleHint:
130
130
  "On: fonts and content scale as the preview fills the screen. Off: blocks still fill the screen, but content stays original size to avoid distortion",
131
+ about: "About",
132
+ versionLabel: "Version",
133
+ versionValue: "{version}",
134
+ versionUnavailable: "Unknown",
131
135
  productName: "Product name",
132
136
  productNamePlaceholder: "Enter the current build product name",
133
137
  uploadTitleIcon: "Upload title icon",
@@ -126,6 +126,10 @@ export const zhCN = {
126
126
  fontLarge: "字体:大",
127
127
  outputScale: "产出缩放",
128
128
  outputScaleHint: "开启后预览撑满时字体和内容一起缩放;关闭后块仍撑满全屏,但内容保持原尺寸以免失真",
129
+ about: "关于",
130
+ versionLabel: "版本",
131
+ versionValue: "{version}",
132
+ versionUnavailable: "未知",
129
133
  productName: "产物名称",
130
134
  productNamePlaceholder: "请输入当前构建产物名称",
131
135
  uploadTitleIcon: "上传 title 图标",
@@ -81,6 +81,25 @@ export function useI18n(): I18nContextValue {
81
81
  return ctx;
82
82
  }
83
83
 
84
+ /** Whether the nearest I18nProvider from *this* package instance is present. */
85
+ export function useHasI18nProvider(): boolean {
86
+ return useContext(I18nContext) != null;
87
+ }
88
+
89
+ /**
90
+ * If no I18nProvider from this package is above, wrap children with one.
91
+ * Fixes Umi/npm duplicate-`@arronqzy/i18n` cases where the panel Provider
92
+ * comes from a different copy than react-blueprint's `useI18n`.
93
+ */
94
+ export function EnsureI18nProvider({
95
+ children,
96
+ ...providerProps
97
+ }: I18nProviderProps) {
98
+ const hasProvider = useHasI18nProvider();
99
+ if (hasProvider) return <>{children}</>;
100
+ return <I18nProvider {...providerProps}>{children}</I18nProvider>;
101
+ }
102
+
84
103
  /** Safe hook: returns zh-CN translator when outside provider (for utilities). */
85
104
  export function useI18nOptional(): I18nContextValue {
86
105
  const ctx = useContext(I18nContext);
@@ -1,2 +1,2 @@
1
- export { I18nProvider, useI18n, useI18nOptional } from "./I18nProvider";
1
+ export { I18nProvider, EnsureI18nProvider, useI18n, useI18nOptional, useHasI18nProvider } from "./I18nProvider";
2
2
  export type { I18nContextValue, I18nProviderProps } from "./I18nProvider";