Skip to content

Commit

Permalink
feat: add Russian translation support (#2248)
Browse files Browse the repository at this point in the history
* refactor: unify export style in sheets-filter-ui locale/en-US.ts

packages/sheets-filter-ui/src/locale/en-US.ts
Changed export default syntax to a named constant for consistency:
- Replaced 'export default {' with 'const locale = {'
- Added 'export default locale;'

* feat: added Russian language to ./packages/*/src/locale and partially updated code

- Added Russian language support to all files in the ./packages/*/src/locale directory.

- Updated code to support Russian language in most places where the language was used.

* chore: run eslint --fix to correct errors and remove warnings

* refactor: optimize code and fix TypeScript type issues

* feat(examples): added Russian language support

---------

Co-authored-by: 白熱 <[email protected]>
  • Loading branch information
niazlv and jikkai committed May 16, 2024
1 parent e58a69e commit 87e0f84
Show file tree
Hide file tree
Showing 73 changed files with 3,149 additions and 46 deletions.
4 changes: 4 additions & 0 deletions examples/src/plugins/debugger/controllers/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
label: '简体中文',
value: LocaleType.ZH_CN,
},
{
label: 'Русский',
value: LocaleType.RU_RU,
},
],
};
}
Expand Down
36 changes: 25 additions & 11 deletions examples/src/sheets/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
*/

import { LocaleType, Tools } from '@univerjs/core';
import { enUS as UniverDesignEnUS } from '@univerjs/design';
import { enUS as UniverDocsUIEnUS } from '@univerjs/docs-ui';
import { enUS as UniverSheetsEnUS } from '@univerjs/sheets';
import { enUS as UniverSheetsUIEnUS } from '@univerjs/sheets-ui';
import { enUS as UniverFindReplaceEnUS } from '@univerjs/find-replace';
import { enUS as UniverSheetsFormulaEnUS } from '@univerjs/sheets-formula';
import { enUS as UniverSheetsDataValidationEnUS } from '@univerjs/sheets-data-validation';
import { enUS as UniverSheetsConditionalFormattingUIEnUS } from '@univerjs/sheets-conditional-formatting-ui';
import { enUS as UniverSheetsZenEditorEnUS } from '@univerjs/sheets-zen-editor';
import { enUS as UniverUIEnUS } from '@univerjs/ui';
import { enUS as UniverSheetsFilterUIEnUS } from '@univerjs/sheets-filter-ui';
import { enUS as UniverDesignEnUS, ruRU as UniverDesignRuRU } from '@univerjs/design';
import { enUS as UniverDocsUIEnUS, ruRU as UniverDocsUIRuRU } from '@univerjs/docs-ui';
import { enUS as UniverSheetsEnUS, ruRU as UniverSheetsRuRU } from '@univerjs/sheets';
import { enUS as UniverSheetsUIEnUS, ruRU as UniverSheetsUIRuRU } from '@univerjs/sheets-ui';
import { enUS as UniverFindReplaceEnUS, ruRU as UniverFindReplaceRuRU } from '@univerjs/find-replace';
import { enUS as UniverSheetsFormulaEnUS, ruRU as UniverSheetsFormulaRuRU } from '@univerjs/sheets-formula';
import { enUS as UniverSheetsDataValidationEnUS, ruRU as UniverSheetsDataValidationRuRU } from '@univerjs/sheets-data-validation';
import { enUS as UniverSheetsConditionalFormattingUIEnUS, ruRU as UniverSheetsConditionalFormattingUIRuRU } from '@univerjs/sheets-conditional-formatting-ui';
import { enUS as UniverSheetsZenEditorEnUS, ruRU as UniverSheetsZenEditorRuRU } from '@univerjs/sheets-zen-editor';
import { enUS as UniverUIEnUS, ruRU as UniverUIRuRU } from '@univerjs/ui';
import { enUS as UniverSheetsFilterUIEnUS, ruRU as UniverSheetsFilterUIRuRU } from '@univerjs/sheets-filter-ui';


export const locales = {
[LocaleType.EN_US]: Tools.deepMerge(
Expand All @@ -41,4 +42,17 @@ export const locales = {
UniverDesignEnUS,
UniverSheetsFilterUIEnUS
),
[LocaleType.RU_RU]: Tools.deepMerge(
UniverSheetsRuRU,
UniverDocsUIRuRU,
UniverFindReplaceRuRU,
UniverSheetsUIRuRU,
UniverSheetsFormulaRuRU,
UniverSheetsDataValidationRuRU,
UniverSheetsConditionalFormattingUIRuRU,
UniverSheetsZenEditorRuRU,
UniverUIRuRU,
UniverDesignRuRU,
UniverSheetsFilterUIRuRU
),
};
1 change: 1 addition & 0 deletions packages/core/src/types/enum/locale-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export enum LocaleType {
EN_US = 'enUS',
ZH_CN = 'zhCN',
RU_RU = 'ruRU',
}

export type LocaleTypes = `${LocaleType}`;
2 changes: 1 addition & 1 deletion packages/design/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export { type ISegmentedProps, Segmented } from './components/segmented';
export { type ISliderProps, Slider } from './components/slider';
export { type ITooltipProps, Tooltip } from './components/tooltip';
export { type ITreeNodeProps, type ITreeProps, Tree, TreeSelectionMode } from './components/tree';
export { enUS, zhCN } from './locale';
export { enUS, zhCN, ruRU } from './locale';
export { type ILocale } from './locale/interface';
export { defaultTheme, greenTheme, themeInstance } from './themes';
export { DraggableList, type IDraggableListProps } from './components/draggable-list';
1 change: 1 addition & 0 deletions packages/design/src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
export { default as enUS } from './en-US';
export { type ILocale } from './interface';
export { default as zhCN } from './zh-CN';
export { default as ruRU } from './ru-RU';
37 changes: 37 additions & 0 deletions packages/design/src/locale/ru-RU.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2023-present DreamNum Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import PickerRuRU from 'rc-picker/lib/locale/ru_RU';
import dajsRuRU from 'dayjs/locale/ru';
import type { ILocale } from './interface';

const locale: ILocale = {
design: {
Confirm: {
cancel: 'отмена',
confirm: 'ок',
},
Slider: {
resetTo: 'Сбросить до',
},
Picker: {
...dajsRuRU,
...PickerRuRU,
},
},
};

export default locale;
2 changes: 1 addition & 1 deletion packages/docs-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

export * from './basics';
export * from './docs-ui-plugin';
export { enUS, zhCN } from './locale';
export { enUS, zhCN, ruRU } from './locale';
export { DocCanvasView } from './views/doc-canvas-view';
export * from './services';
1 change: 1 addition & 0 deletions packages/docs-ui/src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

export { default as enUS } from './en-US';
export { default as zhCN } from './zh-CN';
export { default as ruRU } from './ru-RU';
49 changes: 49 additions & 0 deletions packages/docs-ui/src/locale/ru-RU.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2023-present DreamNum Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type zhCN from './zh-CN';

const locale: typeof zhCN = {
toolbar: {
undo: 'Отменить',
redo: 'Повторить',
font: 'Шрифт',
fontSize: 'Размер шрифта',
bold: 'Полужирный',
italic: 'Курсив',
strikethrough: 'Зачеркнутый',
subscript: 'Нижний индекс',
superscript: 'Верхний индекс',
underline: 'Подчеркнутый',
textColor: {
main: 'Цвет текста',
right: 'Выбрать цвет',
},
fillColor: {
main: 'Цвет фона текста',
right: 'Выбрать цвет',
},
resetColor: 'Сбросить',
order: 'Упорядоченный список',
unorder: 'Неупорядоченный список',
alignLeft: 'Выровнять по левому краю',
alignCenter: 'Выровнять по центру',
alignRight: 'Выровнять по правому краю',
alignJustify: 'Выровнять по ширине',
},
};

export default locale;
2 changes: 1 addition & 1 deletion packages/find-replace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export type {
IReplaceAllResult,
} from './services/find-replace.service';
export { FindModel, IFindReplaceService, FindBy, FindScope, FindDirection } from './services/find-replace.service';
export { enUS, zhCN } from './locale';
export { enUS, zhCN, ruRU } from './locale';
1 change: 1 addition & 0 deletions packages/find-replace/src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

export { default as enUS } from './en-US';
export { default as zhCN } from './zh-CN';
export { default as ruRU } from './ru-RU';
68 changes: 68 additions & 0 deletions packages/find-replace/src/locale/ru-RU.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Copyright 2023-present DreamNum Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type zhCN from './zh-CN';

const locale: typeof zhCN = {
'find-replace': {
toolbar: 'Найти и заменить',
shortcut: {
'open-find-dialog': 'Открыть диалог поиска',
'open-replace-dialog': 'Открыть диалог замены',
'close-dialog': 'Закрыть диалог поиска и замены',
'go-to-next-match': 'Перейти к следующему совпадению',
'go-to-previous-match': 'Перейти к предыдущему совпадению',
},
dialog: {
title: 'Найти',
find: 'Найти',
replace: 'Заменить',
'replace-all': 'Заменить все',
'case-sensitive': 'С учетом регистра',
'find-placeholder': 'Найти в этом листе',
'advanced-finding': 'Расширенный поиск и замена',
'replace-placeholder': 'Введите строку для замены',
'match-the-whole-cell': 'Точное совпадение',
'find-direction': {
title: 'Направление поиска',
row: 'Поиск по строкам',
column: 'Поиск по столбцам',
},
'find-scope': {
title: 'Область поиска',
'current-sheet': 'Текущий лист',
workbook: 'Книга',
},
'find-by': {
title: 'Поиск по',
value: 'Поиск по значению',
formula: 'Поиск по формуле',
},
'no-match': 'Поиск завершен, совпадений не найдено.',
'no-result': 'Нет результатов',
},
replace: {
'all-success': 'Заменены все {0} совпадений',
'all-failure': 'Не удалось заменить',
confirm: {
title: 'Вы уверены, что хотите заменить все совпадения?',
},
},
},
'find-replace-shortcuts': 'Найти и заменить',
};

export default locale;
4 changes: 1 addition & 3 deletions packages/find-replace/src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

import type enUS from './en-US';

const locale: typeof enUS = {
const locale = {
'find-replace': {
toolbar: '查找替换',
shortcut: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import type { Meta } from '@storybook/react';
import type { Dependency } from '@wendellhu/redi';
import { RediContext } from '@wendellhu/redi/react-bindings';
import React, { useContext, useState } from 'react';
import React, { useContext, useMemo, useState } from 'react';

import { DesktopLayoutService, ILayoutService } from '@univerjs/ui';
import { LocaleService, LocaleType } from '@univerjs/core';
import { FindReplaceService, IFindReplaceService } from '../../services/find-replace.service';
import { FindReplaceController } from '../../controllers/find-replace.controller';
import { enUS, zhCN } from '../../locale';
import { enUS, ruRU, zhCN } from '../../locale';
import { FindReplaceDialog } from './FindReplaceDialog';

const meta: Meta = {
Expand All @@ -49,15 +49,18 @@ function FindDialogDemo() {
injector?.get(LocaleService).load({
[LocaleType.EN_US]: enUS,
[LocaleType.ZH_CN]: zhCN,
[LocaleType.RU_RU]: ruRU,
});

deps.forEach((dependency) => injector?.add(dependency));

return injector;
});

const memoizedValue = useMemo(() => ({ injector: inject }), [inject]);

return (
<RediContext.Provider value={{ injector: inject }}>
<RediContext.Provider value={memoizedValue}>
<FindReplaceDialog />
</RediContext.Provider>
);
Expand All @@ -82,15 +85,18 @@ function ReplaceDialogDemo() {
injector?.get(LocaleService).load({
[LocaleType.EN_US]: enUS,
[LocaleType.ZH_CN]: zhCN,
[LocaleType.RU_RU]: ruRU,
});

deps.forEach((dependency) => injector?.add(dependency));

return injector;
});

const memoizedValue = useMemo(() => ({ injector: inject }), [inject]);

return (
<RediContext.Provider value={{ injector: inject }}>
<RediContext.Provider value={memoizedValue}>
<FindReplaceDialog />
</RediContext.Provider>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/sheets-conditional-formatting-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

export { UniverSheetsConditionalFormattingUIPlugin } from './plugin';
export { enUS, zhCN } from './locale';
export { enUS, zhCN, ruRU } from './locale';
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

export { default as enUS } from './en-US';
export { default as zhCN } from './zh-CN';
export { default as ruRU } from './ru-RU';
Loading

0 comments on commit 87e0f84

Please sign in to comment.