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.

feat(numfmt): add numfmt local enum (#4472)

Gpound.liu2dcdfa4c7abd
diff --git a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx b/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
index 66db187677..5a87fdf8a1 100644
--- a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
+++ b/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
@@ -16,9 +16,9 @@
import type { FormatType } from '@univerjs/sheets';
-import { ICommandService, LocaleService, Range, useDependency, useInjector } from '@univerjs/core';
+import { ICommandService, LocaleService, Range, useDependency } from '@univerjs/core';
import { SheetsSelectionsService } from '@univerjs/sheets';
-import { getPatternPreview, getPatternType, SetNumfmtCommand } from '@univerjs/sheets-numfmt';
+import { getPatternPreview, getPatternType, SetNumfmtCommand, SheetsNumfmtCellContentController } from '@univerjs/sheets-numfmt';
import { ILayoutService } from '@univerjs/ui';
import React from 'react';
import { OpenNumfmtPanelOperator } from '../../../commands/operations/open.numfmt.panel.operation';
@@ -40,7 +40,7 @@ export const Options = () => {
const commandService = useDependency(ICommandService);
const localeService = useDependency(LocaleService);
const layoutService = useDependency(ILayoutService);
- const injector = useInjector();
+ const sheetsNumfmtCellContentController = useDependency(SheetsNumfmtCellContentController);
const selectionManagerService = useDependency(SheetsSelectionsService);
const setNumfmt = (pattern: string | null) => {
@@ -91,7 +91,7 @@ export const Options = () => {
>
<div>{localeService.t(item.label)}</div>
<div className="m-l-26">
- {item.pattern ? getPatternPreview(item.pattern || '', defaultValue, localeService.getCurrentLocale()).result : ''}
+ {item.pattern ? getPatternPreview(item.pattern || '', defaultValue, sheetsNumfmtCellContentController.local).result : ''}
</div>
</div>
);
diff --git a/packages/sheets-numfmt/src/facade/f-workbook.ts b/packages/sheets-numfmt/src/facade/f-workbook.ts
index ef0c1b3da8..8fb6cf17b1 100644
--- a/packages/sheets-numfmt/src/facade/f-workbook.ts
+++ b/packages/sheets-numfmt/src/facade/f-workbook.ts
@@ -19,14 +19,13 @@ import { SheetsNumfmtCellContentController } from '@univerjs/sheets-numfmt';
import { FWorkbook } from '@univerjs/sheets/facade';
export interface IFWorkbookNumfmtMixin {
- // TODO@wzhudev: should separate numfmt package to two
/**
* @example
* ```ts
* univerAPI.getActiveWorkbook().setNumfmtLocal('en')
* ```
- * @param {INumfmtLocalTag} local
+ * @param {INumfmtLocalTag} local zh_CN,zh_TW,zh_HK,ja,ko,th,cs,da,nl,en,en_AU,en_CA,en_GB,en_IE,fi,fr,fr_CA,fr_CH,de,de_CH,el,hu,is,id,it,it_CH,nb,no,pl,pt,pt_BR,ru,sk,es,es_AR,es_BO,es_CL,es_CO,es_EC,es_MX,es_PY,es_UY,es_VE,sv,tr,cy,az,be,bg,ca,fil,gu,he,hr,hy,ka,kk,kn,lt,lv,ml,mn,mr,my,pa,ro,sl,sr,ta,te,uk,vi,ar,bn,hi
* @returns {*} {FWorkbook}
* @memberof IFWorkbookNumfmtMixin
*/