Skip to content

Commit

Permalink
feat: add i18n support for notebook kernel panel
Browse files Browse the repository at this point in the history
  • Loading branch information
ensorrow committed Nov 13, 2024
1 parent 6417ff0 commit 20a4615
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
8 changes: 8 additions & 0 deletions packages/i18n/src/common/en-US.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,14 @@ export const localizationBundle = {

'webview.webviewTagUnavailable': 'webview is unsupported on non-electron env, please use iframe instead',

// #region notebook
'notebook.kernel.panel.empty': 'No content found.',
'notebook.kernel.panel.title': 'Running Terminals and Kernels',
'notebook.kernel.panel.opened.pages': 'Opened Pages',
'notebook.kernel.panel.running.kernels': 'Running Kernels',
'notebook.kernel.close.all.confirmation': 'Are you sure you want to close all?',
// #endregion notebook

...browserViews,
...editorLocalizations,
...mergeConflicts,
Expand Down
8 changes: 8 additions & 0 deletions packages/i18n/src/common/zh-CN.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,14 @@ export const localizationBundle = {

'webview.webviewTagUnavailable': '非 Electron 环境不支持 webview 标签,请使用 iframe 标签',

// #region notebook
'notebook.kernel.panel.empty': '暂无内容',
'notebook.kernel.panel.title': '运行的终端和内核',
'notebook.kernel.panel.opened.pages': '已开启的标签页',
'notebook.kernel.panel.running.kernels': '运行的内核',
'notebook.kernel.close.all.confirmation': '你确定要关闭全部吗?',
// #endregion notebook

...browserViews,
...editorLocalizations,
...mergeConflicts,
Expand Down
20 changes: 12 additions & 8 deletions packages/notebook/src/browser/kernel-panel/collapse/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons';
import { ConfigProvider, Empty, Popconfirm, message, theme } from 'antd';
import React, { useEffect, useState } from 'react';

import { useInjectable } from '@opensumi/ide-core-browser';
import { localize, useInjectable } from '@opensumi/ide-core-browser';
import { IThemeService } from '@opensumi/ide-theme/lib/common';

import {
Expand All @@ -23,7 +23,11 @@ const getCollapseContentView = (
) => {
if (!items) {
return (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description='暂无内容' className='kernel-and-terminal-panel-empty' />
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={localize('notebook.kernel.panel.empty')}
className='kernel-and-terminal-panel-empty'
/>
);
}

Expand All @@ -41,9 +45,9 @@ const getCollapseContentView = (
const getCollapseHeaderLabel = (type: LibroPanelCollapseItemType) => {
switch (type) {
case LibroPanelCollapseItemType.PAGE:
return '已开启的标签页';
return localize('notebook.kernel.panel.opened.pages');
case LibroPanelCollapseItemType.KERNEL:
return '运行的内核';
return localize('notebook.kernel.panel.running.kernels');
}
};

Expand Down Expand Up @@ -80,9 +84,9 @@ export const LibroCollapse: React.FC<Props> = (props: Props) => {
</div>
<div className='libro-panel-collapse-header-close-all'>
<Popconfirm
title='你确定要关闭全部吗?'
okText='确定'
cancelText='取消'
title={localize('notebook.kernel.close.all.confirmation')}
okText={localize('ButtonOK')}
cancelText={localize('ButtonCancel')}
onConfirm={() => {
if (props.shutdownAll) {
props
Expand All @@ -96,7 +100,7 @@ export const LibroCollapse: React.FC<Props> = (props: Props) => {
}
}}
>
关闭全部
{localize('editor.closeAllInGroup')}
</Popconfirm>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Container } from '@difizen/mana-app';
import { useEffect, useState } from 'react';
import React from 'react';

import { useInjectable } from '@opensumi/ide-core-browser';
import { localize, useInjectable } from '@opensumi/ide-core-browser';
import { IThemeService } from '@opensumi/ide-theme/lib/common';

import { ManaContainer } from '../mana';
Expand Down Expand Up @@ -78,7 +78,7 @@ export const KernelPanel: React.FC = () => {
return (
<div className='kernel-and-panel' key={refresh}>
<div className='kernel-and-panel-header'>
<div className='kernel-and-panel-title'>运行的终端和内核</div>
<div className='kernel-and-panel-title'>{localize('notebook.kernel.panel.title')}</div>
<img
width={16}
height={16}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Autowired } from '@opensumi/di';
import { ComponentContribution, ComponentRegistry, Domain } from '@opensumi/ide-core-browser';
import { ComponentContribution, ComponentRegistry, Domain, localize } from '@opensumi/ide-core-browser';
import { IconService } from '@opensumi/ide-theme/lib/browser';
import { IconType } from '@opensumi/ide-theme/lib/common';

Expand All @@ -23,7 +23,7 @@ export class KernelPanelContribution implements ComponentContribution {
registry.register('@opensumi/ide-notebook', [], {
containerId: KERNEL_PANEL_ID,
iconClass,
title: '运行的终端和内核',
title: localize('notebook.kernel.panel.title'),
component: KernelPanel,
priority: 0,
activateKeyBinding: 'ctrlcmd+shift+k',
Expand Down

0 comments on commit 20a4615

Please sign in to comment.