[i18n] g global namespace (#1843)

* Batch move global scope i18n to g. namespace

* Minor fix

* Update locale

* Update locales [skip ci]

* More moves

* Regroup icon/color

* nit

* Fix component test

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-07 19:07:03 -08:00
committed by GitHub
parent a76159e9a0
commit b6038128cb
40 changed files with 414 additions and 360 deletions

View File

@@ -22,7 +22,7 @@
</span>
<div v-if="imageBroken" class="broken-image-placeholder">
<i class="pi pi-image"></i>
<span>{{ $t('imageFailedToLoad') }}</span>
<span>{{ $t('g.imageFailedToLoad') }}</span>
</div>
</template>

View File

@@ -1,8 +1,8 @@
<template>
<Dialog v-model:visible="visible" :header="$t('customizeFolder')">
<Dialog v-model:visible="visible" :header="$t('g.customizeFolder')">
<div class="p-fluid">
<div class="field icon-field">
<label for="icon">{{ $t('icon') }}</label>
<label for="icon">{{ $t('g.icon') }}</label>
<SelectButton
v-model="selectedIcon"
:options="iconOptions"
@@ -19,7 +19,7 @@
</div>
<Divider />
<div class="field color-field">
<label for="color">{{ $t('color') }}</label>
<label for="color">{{ $t('g.color') }}</label>
<div class="color-picker-container">
<SelectButton
v-model="selectedColor"
@@ -41,7 +41,7 @@
v-else
class="pi pi-palette"
:style="{ fontSize: '1.2rem' }"
v-tooltip="$t('customColor')"
v-tooltip="$t('g.customColor')"
></i>
</template>
</SelectButton>
@@ -54,13 +54,13 @@
</div>
<template #footer>
<Button
:label="$t('reset')"
:label="$t('g.reset')"
icon="pi pi-refresh"
@click="resetCustomization"
class="p-button-text"
/>
<Button
:label="$t('confirm')"
:label="$t('g.confirm')"
icon="pi pi-check"
@click="confirmCustomization"
autofocus
@@ -100,24 +100,24 @@ const visible = computed({
const nodeBookmarkStore = useNodeBookmarkStore()
const iconOptions = [
{ name: t('bookmark'), value: nodeBookmarkStore.defaultBookmarkIcon },
{ name: t('folder'), value: 'pi-folder' },
{ name: t('star'), value: 'pi-star' },
{ name: t('heart'), value: 'pi-heart' },
{ name: t('file'), value: 'pi-file' },
{ name: t('inbox'), value: 'pi-inbox' },
{ name: t('box'), value: 'pi-box' },
{ name: t('briefcase'), value: 'pi-briefcase' }
{ name: t('icon.bookmark'), value: nodeBookmarkStore.defaultBookmarkIcon },
{ name: t('icon.folder'), value: 'pi-folder' },
{ name: t('icon.star'), value: 'pi-star' },
{ name: t('icon.heart'), value: 'pi-heart' },
{ name: t('icon.file'), value: 'pi-file' },
{ name: t('icon.inbox'), value: 'pi-inbox' },
{ name: t('icon.box'), value: 'pi-box' },
{ name: t('icon.briefcase'), value: 'pi-briefcase' }
]
const colorOptions = [
{ name: t('default'), value: nodeBookmarkStore.defaultBookmarkColor },
{ name: t('blue'), value: '#007bff' },
{ name: t('green'), value: '#28a745' },
{ name: t('red'), value: '#dc3545' },
{ name: t('pink'), value: '#e83e8c' },
{ name: t('yellow'), value: '#ffc107' },
{ name: t('custom'), value: 'custom' }
{ name: t('color.default'), value: nodeBookmarkStore.defaultBookmarkColor },
{ name: t('color.blue'), value: '#007bff' },
{ name: t('color.green'), value: '#28a745' },
{ name: t('color.red'), value: '#dc3545' },
{ name: t('color.pink'), value: '#e83e8c' },
{ name: t('color.yellow'), value: '#ffc107' },
{ name: t('color.custom'), value: 'custom' }
]
const defaultIcon = iconOptions.find(
@@ -157,7 +157,7 @@ const resetCustomization = () => {
selectedColor.value = defaultColor
} else if (!colorOption) {
customColor.value = props.initialColor.replace('#', '')
selectedColor.value = { name: 'Custom', value: 'custom' }
selectedColor.value = { name: t('color.custom'), value: 'custom' }
} else {
selectedColor.value = colorOption
}

View File

@@ -14,7 +14,7 @@
<div class="file-action">
<Button
class="file-action-button"
:label="$t('download') + ' (' + fileSize + ')'"
:label="$t('g.download') + ' (' + fileSize + ')'"
size="small"
outlined
:disabled="props.error"

View File

@@ -12,7 +12,7 @@
<div class="file-action">
<Button
class="file-action-button"
:label="$t('download') + ' (' + fileSize + ')'"
:label="$t('g.download') + ' (' + fileSize + ')'"
size="small"
outlined
:disabled="props.error"

View File

@@ -1,7 +1,7 @@
<template>
<div class="system-stats">
<div class="mb-6">
<h2 class="text-2xl font-semibold mb-4">{{ $t('systemInfo') }}</h2>
<h2 class="text-2xl font-semibold mb-4">{{ $t('g.systemInfo') }}</h2>
<div class="grid grid-cols-2 gap-2">
<template v-for="col in systemColumns" :key="col.field">
<div class="font-medium">{{ col.header }}</div>
@@ -13,7 +13,7 @@
<Divider />
<div>
<h2 class="text-2xl font-semibold mb-4">{{ $t('devices') }}</h2>
<h2 class="text-2xl font-semibold mb-4">{{ $t('g.devices') }}</h2>
<TabView v-if="props.stats.devices.length > 1">
<TabPanel
v-for="device in props.stats.devices"

View File

@@ -130,13 +130,13 @@ const deleteCommand = async (node: RenderedTreeExplorerNode) => {
const menuItems = computed<MenuItem[]>(() =>
[
{
label: t('rename'),
label: t('g.rename'),
icon: 'pi pi-file-edit',
command: () => renameCommand(menuTargetNode.value),
visible: menuTargetNode.value?.handleRename !== undefined
},
{
label: t('delete'),
label: t('g.delete'),
icon: 'pi pi-trash',
command: () => deleteCommand(menuTargetNode.value),
visible: menuTargetNode.value?.handleDelete !== undefined,

View File

@@ -128,7 +128,7 @@ describe('TreeExplorerTreeNode', () => {
expect(handleRenameMock).toHaveBeenCalledOnce()
expect(addToastSpy).toHaveBeenCalledWith({
severity: 'error',
summary: 'error',
summary: 'g.error',
detail: 'Rename failed',
life: 3000
})

View File

@@ -6,7 +6,7 @@
</ul>
<div class="flex gap-4 justify-end">
<Button
:label="$t('cancel')"
:label="$t('g.cancel')"
icon="pi pi-undo"
severity="secondary"
@click="onCancel"
@@ -14,26 +14,26 @@
/>
<Button
v-if="type === 'delete'"
:label="$t('delete')"
:label="$t('g.delete')"
severity="danger"
@click="onConfirm"
icon="pi pi-trash"
/>
<Button
v-else-if="type === 'overwrite'"
:label="$t('overwrite')"
:label="$t('g.overwrite')"
severity="warn"
@click="onConfirm"
icon="pi pi-save"
/>
<template v-else-if="type === 'dirtyClose'">
<Button
:label="$t('no')"
:label="$t('g.no')"
severity="secondary"
@click="onDeny"
icon="pi pi-times"
/>
<Button :label="$t('save')" @click="onConfirm" icon="pi pi-save" />
<Button :label="$t('g.save')" @click="onConfirm" icon="pi pi-save" />
</template>
<Button
v-else-if="type === 'reinstall'"
@@ -45,7 +45,7 @@
<!-- Invalid - just show a close button. -->
<Button
v-else
:label="$t('close')"
:label="$t('g.close')"
severity="primary"
@click="onCancel"
icon="pi pi-times"

View File

@@ -7,7 +7,7 @@
<div class="comfy-error-report">
<Button
v-show="!reportOpen"
:label="$t('showReport')"
:label="$t('g.showReport')"
@click="showReport"
text
/>
@@ -28,7 +28,7 @@
/>
<Button
v-if="reportOpen"
:label="$t('copyToClipboard')"
:label="$t('g.copyToClipboard')"
icon="pi pi-copy"
@click="copyReportToClipboard"
/>

View File

@@ -10,7 +10,7 @@
/>
<label>{{ message }}</label>
</FloatLabel>
<Button @click="onConfirm">{{ $t('confirm') }}</Button>
<Button @click="onConfirm">{{ $t('g.confirm') }}</Button>
</div>
</template>

View File

@@ -5,7 +5,7 @@
class="settings-search-box w-full mb-2"
v-model:modelValue="searchQuery"
@search="handleSearch"
:placeholder="$t('searchSettings') + '...'"
:placeholder="$t('g.searchSettings') + '...'"
/>
<Listbox
v-model="activeCategory"

View File

@@ -1,7 +1,7 @@
<template>
<Button
@click="openGitHubIssues"
:label="$t('findIssues')"
:label="$t('g.findIssues')"
severity="secondary"
icon="pi pi-github"
>

View File

@@ -1,11 +1,11 @@
<template>
<Button
@click="reportIssue"
:label="$t('reportIssue')"
:label="$t('g.reportIssue')"
:severity="submitted ? 'success' : 'secondary'"
:icon="icon"
:disabled="submitted"
v-tooltip="$t('reportIssueTooltip')"
v-tooltip="$t('g.reportIssueTooltip')"
>
</Button>
</template>
@@ -41,7 +41,7 @@ const reportIssue = async () => {
submitted.value = true
toast.add({
severity: 'success',
summary: t('reportSent'),
summary: t('g.reportSent'),
life: 3000
})
} finally {

View File

@@ -1,6 +1,6 @@
<template>
<PanelTemplate value="About" class="about-container">
<h2 class="text-2xl font-bold mb-2">{{ $t('about') }}</h2>
<h2 class="text-2xl font-bold mb-2">{{ $t('g.about') }}</h2>
<div class="space-y-2">
<a
v-for="badge in aboutPanelStore.badges"

View File

@@ -7,7 +7,9 @@
pt:text="w-full"
>
<div class="flex items-center justify-between">
<div>{{ $t('currentUser') }}: {{ userStore.currentUser?.username }}</div>
<div>
{{ $t('g.currentUser') }}: {{ userStore.currentUser?.username }}
</div>
<Button icon="pi pi-sign-out" @click="logout" text />
</div>
</Message>

View File

@@ -3,7 +3,7 @@
<template #header>
<SearchBox
v-model="filters['global'].value"
:placeholder="$t('searchExtensions') + '...'"
:placeholder="$t('g.searchExtensions') + '...'"
/>
<Message v-if="hasChanges" severity="info" pt:text="w-full">
<ul>
@@ -16,7 +16,7 @@
</ul>
<div class="flex justify-end">
<Button
:label="$t('reloadToApplyChanges')"
:label="$t('g.reloadToApplyChanges')"
@click="applyChanges"
outlined
severity="danger"
@@ -30,7 +30,7 @@
size="small"
:filters="filters"
>
<Column field="name" :header="$t('extensionName')" sortable></Column>
<Column field="name" :header="$t('g.extensionName')" sortable></Column>
<Column
:pt="{
bodyCell: 'flex items-center justify-end'

View File

@@ -6,7 +6,7 @@
:closable="true"
@close="handleClose"
>
{{ $t('firstTimeUIMessage') }}
{{ $t('g.firstTimeUIMessage') }}
</Message>
</template>

View File

@@ -3,7 +3,7 @@
<template #header>
<SearchBox
v-model="filters['global'].value"
:placeholder="$t('searchKeybindings') + '...'"
:placeholder="$t('g.searchKeybindings') + '...'"
/>
</template>
@@ -102,8 +102,8 @@
</Dialog>
<Button
class="mt-4"
:label="$t('reset')"
v-tooltip="$t('resetKeybindingsTooltip')"
:label="$t('g.reset')"
v-tooltip="$t('g.resetKeybindingsTooltip')"
icon="pi pi-trash"
severity="danger"
fluid

View File

@@ -6,10 +6,10 @@
@update:formValue="updateSettingValue"
>
<template #name-prefix>
<Tag v-if="setting.experimental" :value="$t('experimental')" />
<Tag v-if="setting.experimental" :value="$t('g.experimental')" />
<Tag
v-if="setting.deprecated"
:value="$t('deprecated')"
:value="$t('g.deprecated')"
severity="danger"
/>
</template>

View File

@@ -10,8 +10,8 @@
<NoResultsPlaceholder
v-else
icon="pi pi-search"
:title="$t('noResultsFound')"
:message="$t('searchFailedMessage')"
:title="$t('g.noResultsFound')"
:message="$t('g.searchFailedMessage')"
/>
</template>

View File

@@ -2,7 +2,7 @@
<div>
<h2 class="px-4">
<i class="pi pi-cog"></i>
<span>{{ $t('settings') }}</span>
<span>{{ $t('g.settings') }}</span>
</h2>
</div>
</template>

View File

@@ -62,7 +62,7 @@
<div>
<label class="text-neutral-200 font-medium">
{{ $t('install.customNodes') }}
<Tag severity="secondary"> {{ $t('comingSoon') }}... </Tag>
<Tag severity="secondary"> {{ $t('g.comingSoon') }}... </Tag>
</label>
<p class="text-sm text-neutral-400 my-1">
{{ $t('install.customNodesDescription') }}

View File

@@ -105,7 +105,7 @@ const suggestions = ref<ComfyNodeDefImpl[]>([])
const hoveredSuggestion = ref<ComfyNodeDefImpl | null>(null)
const currentQuery = ref('')
const placeholder = computed(() => {
return props.filters.length === 0 ? t('searchNodes') + '...' : ''
return props.filters.length === 0 ? t('g.searchNodes') + '...' : ''
})
const nodeDefStore = useNodeDefStore()

View File

@@ -16,7 +16,7 @@
/>
</div>
<div class="_footer">
<Button type="button" :label="$t('add')" @click="submit"></Button>
<Button type="button" :label="$t('g.add')" @click="submit"></Button>
</div>
</template>

View File

@@ -25,12 +25,12 @@
<div class="option-badges">
<Tag
v-if="nodeDef.experimental"
:value="$t('experimental')"
:value="$t('g.experimental')"
severity="primary"
/>
<Tag
v-if="nodeDef.deprecated"
:value="$t('deprecated')"
:value="$t('g.deprecated')"
severity="danger"
/>
<Tag

View File

@@ -3,7 +3,7 @@
icon="pi pi-cog"
class="comfy-settings-btn"
@click="showSetting"
:tooltip="$t('settings')"
:tooltip="$t('g.settings')"
/>
</template>

View File

@@ -9,21 +9,21 @@
@click="modelStore.loadModelFolders"
severity="secondary"
text
v-tooltip.bottom="$t('refresh')"
v-tooltip.bottom="$t('g.refresh')"
/>
<Button
icon="pi pi-cloud-download"
@click="modelStore.loadModels"
severity="secondary"
text
v-tooltip.bottom="$t('loadAllFolders')"
v-tooltip.bottom="$t('g.loadAllFolders')"
/>
</template>
<template #header>
<SearchBox
class="model-lib-search-box p-2 2xl:p-4"
v-model:modelValue="searchQuery"
:placeholder="$t('searchModels') + '...'"
:placeholder="$t('g.searchModels') + '...'"
@search="handleSearch"
/>
</template>

View File

@@ -10,7 +10,7 @@
text
severity="secondary"
@click="nodeBookmarkTreeExplorerRef?.addNewBookmarkFolder()"
v-tooltip.bottom="$t('newFolder')"
v-tooltip.bottom="$t('g.newFolder')"
/>
<Button
class="sort-button"
@@ -28,7 +28,7 @@
@search="handleSearch"
@show-filter="($event) => searchFilter.toggle($event)"
@remove-filter="onRemoveFilter"
:placeholder="$t('searchNodes') + '...'"
:placeholder="$t('g.searchNodes') + '...'"
filter-icon="pi pi-filter"
:filters
/>

View File

@@ -75,8 +75,8 @@
<div v-else>
<NoResultsPlaceholder
icon="pi pi-info-circle"
:title="$t('noTasksFound')"
:message="$t('noTasksFoundMessage')"
:title="$t('g.noTasksFound')"
:message="$t('g.noTasksFoundMessage')"
/>
</div>
</template>
@@ -241,19 +241,19 @@ const menuTargetTask = ref<TaskItemImpl | null>(null)
const menuTargetNode = ref<ComfyNode | null>(null)
const menuItems = computed<MenuItem[]>(() => [
{
label: t('delete'),
label: t('g.delete'),
icon: 'pi pi-trash',
command: () => menuTargetTask.value && removeTask(menuTargetTask.value),
disabled: isExpanded.value || isInFolderView.value
},
{
label: t('loadWorkflow'),
label: t('g.loadWorkflow'),
icon: 'pi pi-file-export',
command: () => menuTargetTask.value?.loadWorkflow(app),
disabled: !menuTargetTask.value?.workflow
},
{
label: t('goToNode'),
label: t('g.goToNode'),
icon: 'pi pi-arrow-circle-right',
command: () => app.goToNode(menuTargetNode.value?.id),
visible: !!menuTargetNode.value

View File

@@ -31,7 +31,7 @@
class="workflows-search-box p-2 2xl:p-4"
v-model:modelValue="searchQuery"
@search="handleSearch"
:placeholder="$t('searchWorkflows') + '...'"
:placeholder="$t('g.searchWorkflows') + '...'"
/>
</template>
<template #body>
@@ -116,8 +116,8 @@
<NoResultsPlaceholder
v-else
icon="pi pi-folder"
:title="$t('empty')"
:message="$t('noWorkflowsFound')"
:title="$t('g.empty')"
:message="$t('g.noWorkflowsFound')"
/>
</div>
</div>
@@ -278,7 +278,7 @@ const renderTreeNode = (
contextMenuItems: (node: TreeExplorerNode<ComfyWorkflow>) => {
return [
{
label: t('insert'),
label: t('g.insert'),
icon: 'pi pi-file-export',
command: () => {
const workflow = node.data

View File

@@ -93,7 +93,7 @@ const extraMenuItems = (
menuTargetNode: RenderedTreeExplorerNode<ComfyNodeDefImpl>
) => [
{
label: t('newFolder'),
label: t('g.newFolder'),
icon: 'pi pi-folder-plus',
command: () => {
addNewBookmarkFolder(menuTargetNode)
@@ -101,7 +101,7 @@ const extraMenuItems = (
visible: !menuTargetNode?.leaf
},
{
label: t('customize'),
label: t('g.customize'),
icon: 'pi pi-palette',
command: () => {
const customization =

View File

@@ -4,12 +4,12 @@
<template #before-label>
<Tag
v-if="nodeDef.experimental"
:value="$t('experimental')"
:value="$t('g.experimental')"
severity="primary"
/>
<Tag
v-if="nodeDef.deprecated"
:value="$t('deprecated')"
:value="$t('g.deprecated')"
severity="danger"
/>
</template>

View File

@@ -1,7 +1,7 @@
<template>
<video controls width="100%" height="100%">
<source :src="url" :type="htmlVideoType" />
{{ $t('videoFailedToLoad') }}
{{ $t('g.videoFailedToLoad') }}
</video>
</template>