mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 02:06:01 +00:00
Refactor to use _val for translation handling across components
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
import Link from '../elements/Link.svelte';
|
import Link from '../elements/Link.svelte';
|
||||||
import { focusedConnectionOrDatabase } from '../stores';
|
import { focusedConnectionOrDatabase } from '../stores';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
|
import { _val } from '../translations';
|
||||||
|
|
||||||
export let list;
|
export let list;
|
||||||
export let module;
|
export let module;
|
||||||
@@ -40,12 +41,12 @@
|
|||||||
|
|
||||||
$: listTranslated = (list || []).map(data => ({
|
$: listTranslated = (list || []).map(data => ({
|
||||||
...data,
|
...data,
|
||||||
group: data?.group && _.isFunction(data.group) ? data.group() : data.group,
|
group: data?.group && _val(data.group),
|
||||||
title: data?.title && _.isFunction(data.title) ? data.title() : data.title,
|
title: data?.title && _val(data.title),
|
||||||
description: data?.description && _.isFunction(data.description) ? data.description() : data.description,
|
description: data?.description && _val(data.description),
|
||||||
args: (data?.args || []).map(x => ({
|
args: (data?.args || []).map(x => ({
|
||||||
...x,
|
...x,
|
||||||
label: x?.label && _.isFunction(x.label) ? x.label() : x.label,
|
label: x?.label && _val(x.label),
|
||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
function getCommandTitle(command) {
|
function getCommandTitle(command) {
|
||||||
let res = _.isFunction(command.text) ? command.text() : command.text;
|
let res = _val(command.text);
|
||||||
if (command.keyText || command.keyTextFromGroup) {
|
if (command.keyText || command.keyTextFromGroup) {
|
||||||
res += ` (${formatKeyText(command.keyText || command.keyTextFromGroup)})`;
|
res += ` (${formatKeyText(command.keyText || command.keyTextFromGroup)})`;
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
import { formatKeyText } from '../utility/common';
|
import { formatKeyText } from '../utility/common';
|
||||||
import ToolStripButton from './ToolStripButton.svelte';
|
import ToolStripButton from './ToolStripButton.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { _val } from '../translations';
|
||||||
|
|
||||||
export let command;
|
export let command;
|
||||||
export let component = ToolStripButton;
|
export let component = ToolStripButton;
|
||||||
@@ -33,6 +34,6 @@
|
|||||||
{iconAfter}
|
{iconAfter}
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
{(_.isFunction(buttonLabel) ? buttonLabel() : buttonLabel) || (_.isFunction(cmd?.toolbarName) ? cmd.toolbarName() : cmd.toolbarName) || (_.isFunction(cmd?.name) ? cmd.name() : cmd.name)}
|
{(_val(buttonLabel) || _val(cmd?.toolbarName) || _val(cmd?.name))}
|
||||||
</svelte:component>
|
</svelte:component>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
import ToolStripCommandButton from './ToolStripCommandButton.svelte';
|
import ToolStripCommandButton from './ToolStripCommandButton.svelte';
|
||||||
import ToolStripDropDownButton from './ToolStripDropDownButton.svelte';
|
import ToolStripDropDownButton from './ToolStripDropDownButton.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { _val } from '../translations';
|
||||||
export let quickExportHandlerRef = null;
|
export let quickExportHandlerRef = null;
|
||||||
export let command = 'sqlDataGrid.export';
|
export let command = 'sqlDataGrid.export';
|
||||||
export let label = 'Export';
|
export let label = 'Export';
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
|
|
||||||
{#if hasPermission('dbops/export')}
|
{#if hasPermission('dbops/export')}
|
||||||
{#if quickExportHandlerRef}
|
{#if quickExportHandlerRef}
|
||||||
<ToolStripDropDownButton menu={getExportMenu} label={_.isFunction(label) ? label() : label} icon="icon export" />
|
<ToolStripDropDownButton menu={getExportMenu} label={_val(label)} icon="icon export" />
|
||||||
{:else}
|
{:else}
|
||||||
<ToolStripCommandButton {command} />
|
<ToolStripCommandButton {command} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { commands } from '../stores';
|
import { commands } from '../stores';
|
||||||
import { invalidateCommandDefinitions } from './invalidateCommands';
|
import { invalidateCommandDefinitions } from './invalidateCommands';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { _val } from '../translations';
|
||||||
|
|
||||||
export interface SubCommand {
|
export interface SubCommand {
|
||||||
text: string;
|
text: string;
|
||||||
@@ -43,11 +44,9 @@ export default function registerCommand(command: GlobalCommand) {
|
|||||||
...x,
|
...x,
|
||||||
[command.id]: {
|
[command.id]: {
|
||||||
text:
|
text:
|
||||||
_.isFunction(command.category) || _.isFunction(command.name)
|
_val(command.category) || _val(command.name)
|
||||||
? () =>
|
? () =>
|
||||||
`${_.isFunction(command.category) ? command.category() : command.category}: ${
|
`${_val(command.category)}: ${_val(command.name)}`
|
||||||
_.isFunction(command.name) ? command.name() : command.name
|
|
||||||
}`
|
|
||||||
: `${command.category}: ${command.name}`,
|
: `${command.category}: ${command.name}`,
|
||||||
...command,
|
...command,
|
||||||
enabled: !testEnabled,
|
enabled: !testEnabled,
|
||||||
|
|||||||
@@ -421,7 +421,7 @@
|
|||||||
import { openJsonLinesData } from '../utility/openJsonLinesData';
|
import { openJsonLinesData } from '../utility/openJsonLinesData';
|
||||||
import contextMenuActivator from '../utility/contextMenuActivator';
|
import contextMenuActivator from '../utility/contextMenuActivator';
|
||||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||||
import { __t, _t } from '../translations';
|
import { __t, _t, _val } from '../translations';
|
||||||
import { isProApp } from '../utility/proTools';
|
import { isProApp } from '../utility/proTools';
|
||||||
import SaveArchiveModal from '../modals/SaveArchiveModal.svelte';
|
import SaveArchiveModal from '../modals/SaveArchiveModal.svelte';
|
||||||
import hasPermission from '../utility/hasPermission';
|
import hasPermission from '../utility/hasPermission';
|
||||||
@@ -1795,12 +1795,12 @@
|
|||||||
text: _t('datagrid.copyAdvanced', { defaultMessage: 'Copy advanced'}),
|
text: _t('datagrid.copyAdvanced', { defaultMessage: 'Copy advanced'}),
|
||||||
submenu: [
|
submenu: [
|
||||||
_.keys(copyRowsFormatDefs).map(format => ({
|
_.keys(copyRowsFormatDefs).map(format => ({
|
||||||
text: _.isFunction(copyRowsFormatDefs[format].label) ? copyRowsFormatDefs[format].label() : copyRowsFormatDefs[format].label,
|
text: _val(copyRowsFormatDefs[format].label),
|
||||||
onClick: () => copyToClipboardCore(format),
|
onClick: () => copyToClipboardCore(format),
|
||||||
})),
|
})),
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
_.keys(copyRowsFormatDefs).map(format => ({
|
_.keys(copyRowsFormatDefs).map(format => ({
|
||||||
text: _t('datagrid.setFormat', { defaultMessage: 'Set format: ' }) + (_.isFunction(copyRowsFormatDefs[format].name) ? copyRowsFormatDefs[format].name() : copyRowsFormatDefs[format].name),
|
text: _t('datagrid.setFormat', { defaultMessage: 'Set format: ' }) + (_val(copyRowsFormatDefs[format].name)),
|
||||||
onClick: () => ($copyRowsFormat = format),
|
onClick: () => ($copyRowsFormat = format),
|
||||||
})),
|
})),
|
||||||
|
|
||||||
@@ -1870,7 +1870,7 @@
|
|||||||
return [
|
return [
|
||||||
menu,
|
menu,
|
||||||
{
|
{
|
||||||
text: _.isFunction(copyRowsFormatDefs[$copyRowsFormat].label) ? copyRowsFormatDefs[$copyRowsFormat].label() : copyRowsFormatDefs[$copyRowsFormat].label,
|
text: _val(copyRowsFormatDefs[$copyRowsFormat].label),
|
||||||
onClick: () => copyToClipboardCore($copyRowsFormat),
|
onClick: () => copyToClipboardCore($copyRowsFormat),
|
||||||
keyText: 'CtrlOrCommand+C',
|
keyText: 'CtrlOrCommand+C',
|
||||||
tag: 'copy',
|
tag: 'copy',
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
import { evaluateCondition } from 'dbgate-sqltree';
|
import { evaluateCondition } from 'dbgate-sqltree';
|
||||||
import { compileCompoudEvalCondition } from 'dbgate-filterparser';
|
import { compileCompoudEvalCondition } from 'dbgate-filterparser';
|
||||||
import { chevronExpandIcon } from '../icons/expandIcons';
|
import { chevronExpandIcon } from '../icons/expandIcons';
|
||||||
|
import { _val } from '../translations';
|
||||||
|
|
||||||
export let columns: (TableControlColumn | false)[];
|
export let columns: (TableControlColumn | false)[];
|
||||||
export let rows = null;
|
export let rows = null;
|
||||||
@@ -368,7 +369,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/key}
|
{/key}
|
||||||
{:else}
|
{:else}
|
||||||
{ _.isFunction(row[col.fieldName]) ? row[col.fieldName]() : row[col.fieldName] || ''}
|
{ _val(row[col.fieldName]) || '' }
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import invalidateCommands from '../commands/invalidateCommands';
|
|||||||
import { runGroupCommand } from '../commands/runCommand';
|
import { runGroupCommand } from '../commands/runCommand';
|
||||||
import { currentDropDownMenu, visibleCommandPalette } from '../stores';
|
import { currentDropDownMenu, visibleCommandPalette } from '../stores';
|
||||||
import getAsArray from './getAsArray';
|
import getAsArray from './getAsArray';
|
||||||
|
import { _val } from '../translations';
|
||||||
|
|
||||||
let isContextMenuSupressed = false;
|
let isContextMenuSupressed = false;
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ function mapItem(item, commands) {
|
|||||||
if (command) {
|
if (command) {
|
||||||
const commandText = item.text || command.menuName || command.toolbarName || command.name;
|
const commandText = item.text || command.menuName || command.toolbarName || command.name;
|
||||||
return {
|
return {
|
||||||
text: _.isFunction(commandText) ? commandText() : commandText,
|
text: _val(commandText),
|
||||||
keyText: command.keyText || command.keyTextFromGroup || command.disableHandleKeyText,
|
keyText: command.keyText || command.keyTextFromGroup || command.disableHandleKeyText,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (command.isGroupCommand) {
|
if (command.isGroupCommand) {
|
||||||
|
|||||||
Reference in New Issue
Block a user