Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(docs-ui): load lang error (#4060)

Ran Luo278f7284e360
diff --git a/packages/engine-render/src/components/docs/layout/hyphenation/hyphen.ts b/packages/engine-render/src/components/docs/layout/hyphenation/hyphen.ts
index 936b74d3a2..180638868f 100644
--- a/packages/engine-render/src/components/docs/layout/hyphenation/hyphen.ts
+++ b/packages/engine-render/src/components/docs/layout/hyphenation/hyphen.ts
@@ -15,9 +15,9 @@
*/
import type { IDisposable, Nullable } from '@univerjs/core';
+import type { IHyphenPattern, RawHyphenPattern } from './tools';
import { Lang } from './lang';
import { EnUs } from './patterns/en-us';
-import type { IHyphenPattern, RawHyphenPattern } from './tools';
import { createCharIterator, createStringSlicer, parsePattern, snackToPascal } from './tools';
export class Hyphen implements IDisposable {
@@ -70,7 +70,12 @@ export class Hyphen implements IDisposable {
async loadPattern(lang: Lang) {
let pattern = await import(`./patterns/${lang}.ts`);
- pattern = pattern[snackToPascal(lang)];
+
+ pattern = pattern?.[snackToPascal(lang)];
+
+ if (pattern == null) {
+ return;
+ }
this._patterns.set(lang, parsePattern(pattern));
this._loadExceptionsToCache(lang, pattern);