diff --git a/.changeset/fast-rivers-grin.md b/.changeset/fast-rivers-grin.md new file mode 100644 index 0000000..edf9ed7 --- /dev/null +++ b/.changeset/fast-rivers-grin.md @@ -0,0 +1,17 @@ +--- +'@difizen/babel-preset-mana': patch +'@difizen/mana-observable': patch +'@difizen/umi-plugin-mana': patch +'@difizen/mana-syringe': patch +'@difizen/mana-common': patch +'@difizen/mana-react': patch +'@difizen/mana-react-example': patch +'@difizen/mana-core': patch +'@difizen/mana-l10n': patch +'@difizen/mana-app': patch +'@difizen/mana-umi-example': patch +'@difizen/mana-ui': patch +'@difizen/mana-docs': patch +--- + +fix: localStorage is not defined. diff --git a/packages/mana-l10n/src/l10n/index.ts b/packages/mana-l10n/src/l10n/index.ts index de681db..bc578f8 100644 --- a/packages/mana-l10n/src/l10n/index.ts +++ b/packages/mana-l10n/src/l10n/index.ts @@ -36,7 +36,10 @@ export enum L10nLang { } function getDefaultlang() { - const localeValue = localStorage?.getItem('locale') || locale; + let localeValue = locale; + if (typeof navigator === 'object') { + localeValue = localStorage?.getItem('locale') || locale; + } const localeStr = localeValue.toLowerCase(); if (localeStr === 'zh' || localeStr.startsWith('zh-')) { return L10nLang.zhCN;