diff --git a/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx b/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx
index 9f9f00d2722..752896e7587 100644
--- a/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx
+++ b/packages/sheets-numfmt/src/components/more-numfmt-type/MoreNumfmtType.tsx
@@ -17,7 +17,6 @@
import './index.less';
import { ICommandService, LocaleService, Range } from '@univerjs/core';
-import numfmt from '@univerjs/engine-numfmt';
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
import type { FormatType } from '@univerjs/sheets';
import { SelectionManagerService } from '@univerjs/sheets';
@@ -27,7 +26,7 @@ import React from 'react';
import { MENU_OPTIONS } from '../../base/const/MENU-OPTIONS';
import { SetNumfmtCommand } from '../../commands/commands/set-numfmt.command';
import { OpenNumfmtPanelOperator } from '../../commands/operations/open.numfmt.panel.operation';
-import { getPatternType } from '../../utils/pattern';
+import { getPatternPreview, getPatternType } from '../../utils/pattern';
export const MoreNumfmtType = (props: { value?: string }) => {
const localeService = useDependency(LocaleService);
@@ -88,7 +87,7 @@ export const Options = () => {
>
{localeService.t(item.label)}
- {item.pattern ? numfmt.format(item.pattern || '', defaultValue, { locale: 'zh-CN' }) : ''}
+ {item.pattern ? getPatternPreview(item.pattern || '', defaultValue, localeService.getCurrentLocale()).result : ''}
);
diff --git a/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts
index c2c5b0a96a4..09cefc557a3 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt.cell-content.controller.ts
@@ -20,6 +20,7 @@ import {
Disposable,
ICommandService,
LifecycleStages,
+ LocaleService,
ObjectMatrix,
OnLifecycle,
Range,
@@ -42,7 +43,8 @@ export class NumfmtCellContent extends Disposable {
@Inject(SheetSkeletonManagerService) private _sheetSkeletonManagerService: SheetSkeletonManagerService,
@Inject(ICommandService) private _commandService: ICommandService,
- @Inject(INumfmtService) private _numfmtService: INumfmtService
+ @Inject(INumfmtService) private _numfmtService: INumfmtService,
+ @Inject(LocaleService) private _localeService: LocaleService
) {
super();
this._initInterceptorCellContent();
@@ -74,7 +76,7 @@ export class NumfmtCellContent extends Disposable {
return { ...cell, ...cache.result };
}
- const info = getPatternPreview(numfmtValue.pattern, Number(originCellValue.v));
+ const info = getPatternPreview(numfmtValue.pattern, Number(originCellValue.v), this._localeService.getCurrentLocale());
numfmtRes = info.result;
diff --git a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
index 186b826cb05..aa006e6e8f5 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts
@@ -310,7 +310,7 @@ export class NumfmtController extends Disposable implements INumfmtController {
) {
return next(cell);
}
- const info = getPatternPreview(this._previewPattern, value as number);
+ const info = getPatternPreview(this._previewPattern, value as number, this._localeService.getCurrentLocale());
if (info.color) {
const colorMap = this._themeService.getCurrentTheme();
const color = colorMap[`${info.color}500`];
diff --git a/packages/sheets-numfmt/src/locale/en-US.ts b/packages/sheets-numfmt/src/locale/en-US.ts
index 34a04507584..29736f8f7bd 100644
--- a/packages/sheets-numfmt/src/locale/en-US.ts
+++ b/packages/sheets-numfmt/src/locale/en-US.ts
@@ -19,6 +19,7 @@ import type zhCN from './zh-CN';
const locale: typeof zhCN = {
sheet: {
numfmt: {
+ percent: 'Percentage',
title: 'Number format',
numfmtType: 'Format types',
cancel: 'Cancel',
diff --git a/packages/sheets-numfmt/src/locale/zh-CN.ts b/packages/sheets-numfmt/src/locale/zh-CN.ts
index d3ec9360e46..61ae1303cfa 100644
--- a/packages/sheets-numfmt/src/locale/zh-CN.ts
+++ b/packages/sheets-numfmt/src/locale/zh-CN.ts
@@ -17,6 +17,7 @@
const locale = {
sheet: {
numfmt: {
+ percent: '百分比',
title: '数字格式',
numfmtType: '格式类型',
cancel: '取消',
diff --git a/packages/sheets-numfmt/src/utils/pattern.ts b/packages/sheets-numfmt/src/utils/pattern.ts
index 55e83d1a2c7..1d2e2f3239a 100644
--- a/packages/sheets-numfmt/src/utils/pattern.ts
+++ b/packages/sheets-numfmt/src/utils/pattern.ts
@@ -16,13 +16,14 @@
import numfmt from '@univerjs/engine-numfmt';
import type { FormatType } from '@univerjs/sheets';
+import { LocaleType } from '@univerjs/core';
export const getPatternType = (pattern: string): FormatType => numfmt.getInfo(pattern).type || 'unknown';
-export const getPatternPreview = (pattern: string, value: number) => {
+export const getPatternPreview = (pattern: string, value: number, _locale?: LocaleType) => {
const info = numfmt.getInfo(pattern);
-
+ const locale = _locale === LocaleType.ZH_CN ? 'zh-CN' : 'en';
const negInfo = info._partitions[1];
- const result = numfmt.format(pattern, value, { locale: 'zh-CN' });
+ const result = numfmt.format(pattern, value, { locale });
if (value < 0) {
return {
result,