Translation infrastructure

This commit is contained in:
Eugene Pankov
2022-01-08 16:02:56 +01:00
parent 04010b58bb
commit 0814d44207
134 changed files with 8137 additions and 889 deletions

View File

@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Injectable } from '@angular/core'
import { ToolbarButtonProvider, ToolbarButton } from 'tabby-core'
import { ToolbarButtonProvider, ToolbarButton, TranslateService } from 'tabby-core'
import { TerminalService } from './services/terminal.service'
/** @hidden */
@@ -8,6 +8,7 @@ import { TerminalService } from './services/terminal.service'
export class ButtonProvider extends ToolbarButtonProvider {
constructor (
private terminal: TerminalService,
private translate: TranslateService,
) {
super()
}
@@ -16,7 +17,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
return [
{
icon: require('./icons/plus.svg'),
title: 'New terminal',
title: this.translate.instant('New terminal'),
touchBarNSImage: 'NSTouchBarAddDetailTemplate',
click: () => {
this.terminal.openTab()

View File

@@ -1,6 +1,6 @@
ng-container(*ngIf='!argvMode')
.form-group
label Command line
label(translate) Command line
.input-group
.input-group-prepend
a.input-group-text(
@@ -16,7 +16,7 @@ ng-container(*ngIf='!argvMode')
ng-container(*ngIf='argvMode')
.form-group
label Program
label(translate) Program
.input-group
.input-group-prepend
a.input-group-text(
@@ -31,7 +31,7 @@ ng-container(*ngIf='argvMode')
)
.form-group
label Arguments
label(translate) Arguments
.input-group(
*ngFor='let arg of _model.args; index as i; trackBy: trackByIndex',
)
@@ -46,4 +46,4 @@ ng-container(*ngIf='argvMode')
.mt-2
button.btn.btn-secondary((click)='_model.args.push("")')
i.fas.fa-plus.mr-2
| Add
span(translate) Add

View File

@@ -11,10 +11,10 @@
.d-flex
button.btn.btn-secondary((click)='addEnvironmentVar()')
i.fas.fa-plus.mr-2
span Add
span(translate) Add
.ml-auto
.text-muted Substitutions allowed.
.text-muted(translate) Substitutions allowed.
.d-flex.ml-1(*ngIf='shouldShowExample()')
.text-muted Example:
.text-muted(translate) Example:
a.ml-1((click)='addExample()', href='#') extend PATH

View File

@@ -2,13 +2,13 @@ command-line-editor([model]='profile.options')
.form-line(*ngIf='uac.isAvailable')
.header
.title Run as administrator
.title(translate) Run as administrator
toggle(
[(ngModel)]='profile.options.runAsAdministrator',
)
.form-group
label Working directory
label(translate) Working directory
.input-group
input.form-control(
@@ -21,7 +21,7 @@ command-line-editor([model]='profile.options')
i.fas.fa-folder-open
.form-group
label Environment
label(translate) Environment
environment-editor(
type='text',
[(model)]='profile.options.env',

View File

@@ -1,9 +1,9 @@
h3.mb-3 Shell
h3.mb-3(translate) Shell
.form-line(*ngIf='isConPTYAvailable')
.header
.title Use ConPTY
.description Enables the experimental Windows ConPTY API
.title(translate) Use ConPTY
.description(translate) Enables the experimental Windows ConPTY API
toggle(
[(ngModel)]='config.store.terminal.useConPTY',
@@ -11,7 +11,7 @@ h3.mb-3 Shell
)
.alert.alert-info.d-flex.align-items-center(*ngIf='config.store.terminal.useConPTY && isConPTYAvailable && !isConPTYStable')
.mr-auto Windows 10 build 18309 or above is recommended for ConPTY
.mr-auto(translate) Windows 10 build 18309 or above is recommended for ConPTY
.alert.alert-info.d-flex.align-items-center(*ngIf='config.store.terminal.profile.startsWith("WSL") && (!config.store.terminal.useConPTY)')
.mr-auto WSL terminal only supports TrueColor with ConPTY
.mr-auto(translate) WSL terminal only supports TrueColor with ConPTY

View File

@@ -1,5 +1,5 @@
import { Component, Input, Injector } from '@angular/core'
import { BaseTabProcess, WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild } from 'tabby-core'
import { BaseTabProcess, WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild, TranslateService } from 'tabby-core'
import { BaseTerminalTabComponent } from 'tabby-terminal'
import { LocalProfile, SessionOptions } from '../api'
import { Session } from '../session'
@@ -20,6 +20,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor (
injector: Injector,
private translate: TranslateService,
private uac: UACService,
) {
super(injector)
@@ -108,8 +109,14 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
return (await this.platform.showMessageBox(
{
type: 'warning',
message: `"${children[0].command}" is still running. Close?`,
buttons: ['Kill', 'Cancel'],
message: this.translate.instant(
'"{command}" is still running. Close?',
children[0],
),
buttons: [
this.translate.instant('Kill'),
this.translate.instant('Cancel'),
],
defaultId: 0,
cancelId: 1,
}

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { HotkeyDescription, HotkeyProvider } from 'tabby-core'
import { HotkeyDescription, HotkeyProvider, TranslateService } from 'tabby-core'
/** @hidden */
@Injectable()
@@ -7,10 +7,12 @@ export class LocalTerminalHotkeyProvider extends HotkeyProvider {
hotkeys: HotkeyDescription[] = [
{
id: 'new-tab',
name: 'New tab',
name: this.translate.instant('New tab'),
},
]
constructor (private translate: TranslateService) { super() }
async provide (): Promise<HotkeyDescription[]> {
return this.hotkeys
}

View File

@@ -1,6 +1,6 @@
import deepClone from 'clone-deep'
import { Injectable, Inject } from '@angular/core'
import { ProfileProvider, NewTabParameters, ConfigService, SplitTabComponent, AppService, PartialProfile } from 'tabby-core'
import { ProfileProvider, NewTabParameters, ConfigService, SplitTabComponent, AppService, PartialProfile, TranslateService } from 'tabby-core'
import { TerminalTabComponent } from './components/terminalTab.component'
import { LocalProfileSettingsComponent } from './components/localProfileSettings.component'
import { ShellProvider, Shell, SessionOptions, LocalProfile } from './api'
@@ -8,7 +8,7 @@ import { ShellProvider, Shell, SessionOptions, LocalProfile } from './api'
@Injectable({ providedIn: 'root' })
export class LocalProfilesService extends ProfileProvider<LocalProfile> {
id = 'local'
name = 'Local'
name = this.translate.instant('Local terminal')
settingsComponent = LocalProfileSettingsComponent
configDefaults = {
options: {
@@ -29,6 +29,7 @@ export class LocalProfilesService extends ProfileProvider<LocalProfile> {
constructor (
private app: AppService,
private config: ConfigService,
private translate: TranslateService,
@Inject(ShellProvider) private shellProviders: ShellProvider[],
) {
super()

View File

@@ -1,5 +1,5 @@
import { NgZone, Injectable } from '@angular/core'
import { ConfigService, HostAppService, Platform, ProfilesService } from 'tabby-core'
import { ConfigService, HostAppService, Platform, ProfilesService, TranslateService } from 'tabby-core'
import { ElectronService } from 'tabby-electron'
/** @hidden */
@@ -13,6 +13,7 @@ export class DockMenuService {
private hostApp: HostAppService,
private zone: NgZone,
private profilesService: ProfilesService,
private translate: TranslateService,
) {
config.changed$.subscribe(() => this.update())
}
@@ -21,7 +22,7 @@ export class DockMenuService {
if (this.hostApp.platform === Platform.Windows) {
this.electron.app.setJumpList(this.config.store.profiles.length ? [{
type: 'custom',
name: 'Profiles',
name: this.translate.instant('Profiles'),
items: this.config.store.profiles.map(profile => ({
type: 'task',
program: process.execPath,

View File

@@ -1,6 +1,6 @@
import * as fs from 'mz/fs'
import { Injectable } from '@angular/core'
import { HostAppService, Platform, LogService, Logger } from 'tabby-core'
import { HostAppService, Platform, LogService, Logger, TranslateService } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
@@ -11,6 +11,7 @@ export class LinuxDefaultShellProvider extends ShellProvider {
constructor (
private hostApp: HostAppService,
private translate: TranslateService,
log: LogService,
) {
super()
@@ -27,14 +28,14 @@ export class LinuxDefaultShellProvider extends ShellProvider {
this.logger.warn('Could not detect user shell')
return [{
id: 'default',
name: 'User default',
name: this.translate.instant('User default'),
command: '/bin/sh',
env: {},
}]
} else {
return [{
id: 'default',
name: 'User default',
name: this.translate.instant('User default'),
command: line.split(':')[6],
args: ['--login'],
hidden: true,

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'
import promiseIpc, { RendererProcessType } from 'electron-promise-ipc'
import { HostAppService, Platform } from 'tabby-core'
import { HostAppService, Platform, TranslateService } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
@@ -11,6 +11,7 @@ export class MacOSDefaultShellProvider extends ShellProvider {
constructor (
private hostApp: HostAppService,
private translate: TranslateService,
) {
super()
}
@@ -21,7 +22,7 @@ export class MacOSDefaultShellProvider extends ShellProvider {
}
return [{
id: 'default',
name: 'OS default',
name: this.translate.instant('OS default'),
command: await this.getDefaultShellCached(),
args: ['--login'],
hidden: true,

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { HostAppService, Platform } from 'tabby-core'
import { HostAppService, Platform, TranslateService } from 'tabby-core'
import { ShellProvider, Shell } from '../api'
@@ -17,6 +17,7 @@ export class WindowsDefaultShellProvider extends ShellProvider {
wsl: WSLShellProvider,
stock: WindowsStockShellsProvider,
private hostApp: HostAppService,
private translate: TranslateService,
) {
super()
this.providers = [
@@ -39,7 +40,7 @@ export class WindowsDefaultShellProvider extends ShellProvider {
return [{
...shell,
id: 'default',
name: `OS default (${shell.name})`,
name: this.translate.instant('OS default ({name})', shell),
hidden: true,
env: {},
}]

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, SplitTabComponent, NotificationsService, MenuItemOptions, ProfilesService, PromptModalComponent } from 'tabby-core'
import { ConfigService, BaseTabComponent, TabContextMenuItemProvider, TabHeaderComponent, SplitTabComponent, NotificationsService, MenuItemOptions, ProfilesService, PromptModalComponent, TranslateService } from 'tabby-core'
import { TerminalTabComponent } from './components/terminalTab.component'
import { UACService } from './services/uac.service'
import { TerminalService } from './services/terminal.service'
@@ -13,6 +13,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
private config: ConfigService,
private ngbModal: NgbModal,
private notifications: NotificationsService,
private translate: TranslateService,
) {
super()
}
@@ -23,10 +24,10 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
}
const items: MenuItemOptions[] = [
{
label: 'Save as profile',
label: this.translate.instant('Save as profile'),
click: async () => {
const modal = this.ngbModal.open(PromptModalComponent)
modal.componentInstance.prompt = 'New profile name'
modal.componentInstance.prompt = this.translate.instant('New profile name')
const name = (await modal.result)?.value
if (!name) {
return
@@ -44,7 +45,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
profile,
]
this.config.save()
this.notifications.info('Saved')
this.notifications.info(this.translate.instant('Saved'))
},
},
]
@@ -63,6 +64,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
private profilesService: ProfilesService,
private terminalService: TerminalService,
private uac: UACService,
private translate: TranslateService,
) {
super()
}
@@ -72,7 +74,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
const items: MenuItemOptions[] = [
{
label: 'New terminal',
label: this.translate.instant('New terminal'),
click: () => {
if (tab instanceof TerminalTabComponent) {
this.profilesService.openNewTabForProfile(tab.profile)
@@ -82,7 +84,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
},
},
{
label: 'New with profile',
label: this.translate.instant('New with profile'),
submenu: profiles.map(profile => ({
label: profile.name,
click: async () => {
@@ -98,7 +100,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
if (this.uac.isAvailable) {
items.push({
label: 'New admin tab',
label: this.translate.instant('New admin tab'),
submenu: profiles.map(profile => ({
label: profile.name,
click: () => {
@@ -116,7 +118,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
if (tab instanceof TerminalTabComponent && tabHeader && this.uac.isAvailable) {
items.push({
label: 'Duplicate as administrator',
label: this.translate.instant('Duplicate as administrator'),
click: () => {
this.profilesService.openNewTabForProfile({
...tab.profile,
@@ -131,7 +133,7 @@ export class NewTabContextMenu extends TabContextMenuItemProvider {
if (tab instanceof TerminalTabComponent && tab.parent instanceof SplitTabComponent && tab.parent.getAllTabs().length > 1) {
items.push({
label: 'Focus all panes',
label: this.translate.instant('Focus all panes'),
click: () => {
tab.focusAllPanes()
},