Eugene Pankov 2 лет назад
Родитель
Сommit
8d000a3bd4

+ 2 - 1
tabby-core/src/api/index.ts

@@ -36,6 +36,7 @@ export { TabsService, NewTabParameters, TabComponentType } from '../services/tab
 export { UpdaterService } from '../services/updater.service'
 export { VaultService, Vault, VaultSecret, VaultFileSecret, VAULT_SECRET_TYPE_FILE, StoredVault, VaultSecretKey } from '../services/vault.service'
 export { FileProvidersService } from '../services/fileProviders.service'
-export { LocaleService, TranslateServiceWrapper as TranslateService } from '../services/locale.service'
+export { LocaleService } from '../services/locale.service'
+export { TranslateService } from '@ngx-translate/core'
 export * from '../utils'
 export { UTF8Splitter } from '../utfSplitter'

+ 8 - 14
tabby-core/src/index.ts

@@ -41,7 +41,7 @@ import { AppService } from './services/app.service'
 import { ConfigService } from './services/config.service'
 import { VaultFileProvider } from './services/vault.service'
 import { HotkeysService } from './services/hotkeys.service'
-import { LocaleService, TranslateServiceWrapper } from './services/locale.service'
+import { LocaleService } from './services/locale.service'
 import { CommandService } from './services/commands.service'
 
 import { StandardTheme, StandardCompactTheme, PaperTheme, NewTheme } from './theme'
@@ -82,10 +82,6 @@ const PROVIDERS = [
         provide: MESSAGE_FORMAT_CONFIG,
         useValue: LocaleService.allLanguages.map(x => x.code),
     },
-    {
-        provide: TranslateService,
-        useClass: TranslateServiceWrapper,
-    },
 ]
 
 /** @hidden */
@@ -97,7 +93,13 @@ const PROVIDERS = [
         NgbModule,
         NgxFilesizeModule,
         DragDropModule,
-        TranslateModule,
+        TranslateModule.forRoot({
+            defaultLanguage: 'en',
+            compiler: {
+                provide: TranslateCompiler,
+                useFactory: TranslateMessageFormatCompilerFactory,
+            },
+        }),
     ],
     declarations: [
         AppRootComponent,
@@ -224,18 +226,10 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
     }
 
     static forRoot (): ModuleWithProviders<AppModule> {
-        const translateModule = TranslateModule.forRoot({
-            defaultLanguage: 'en',
-            compiler: {
-                provide: TranslateCompiler,
-                useFactory: TranslateMessageFormatCompilerFactory,
-            },
-        })
         return {
             ngModule: AppModule,
             providers: [
                 ...PROVIDERS,
-                ...translateModule.providers!.filter(x => x !== TranslateService),
             ],
         }
     }

+ 19 - 18
tabby-core/src/services/locale.service.ts

@@ -55,24 +55,6 @@ function flattenMessageFormatTranslation (po: any) {
     return translation
 }
 
-@Injectable({ providedIn: 'root' })
-export class TranslateServiceWrapper extends TranslateService {
-    private _defaultTranslation: Record<string, string>|null
-
-    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-    getParsedResult (translations: any, key: any, interpolateParams?: any): any {
-        if (!this._defaultTranslation) {
-            const po = require(`../../../locale/en-US.po`)
-            this._defaultTranslation = flattenMessageFormatTranslation(po)
-        }
-        this.translations[this.defaultLang][key] ??= this.compiler.compile(
-            this._defaultTranslation[key] || key,
-            this.defaultLang,
-        )
-        return super.getParsedResult(translations, key, interpolateParams ?? {})
-    }
-}
-
 @Injectable({ providedIn: 'root' })
 export class LocaleService {
     private logger: Logger
@@ -176,6 +158,7 @@ export class LocaleService {
         private translate: TranslateService,
         log: LogService,
     ) {
+        this.patchTranslateService(translate)
         this.logger = log.create('translate')
         config.changed$.subscribe(() => {
             this.refresh()
@@ -191,6 +174,24 @@ export class LocaleService {
         }
     }
 
+    private patchTranslateService (translate: TranslateService) {
+        translate['_defaultTranslation'] = null
+        const oldGetParsedResult = translate.getParsedResult.bind(translate)
+
+        // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
+        translate.getParsedResult = function (translations: any, key: any, interpolateParams?: any): any {
+            if (!this._defaultTranslation) {
+                const po = require(`../../../locale/en-US.po`)
+                this._defaultTranslation = flattenMessageFormatTranslation(po)
+            }
+            this.translations[this.defaultLang][key] ??= this.compiler.compile(
+                this._defaultTranslation[key] || key,
+                this.defaultLang,
+            )
+            return oldGetParsedResult(translations, key, interpolateParams ?? {})
+        }.bind(translate)
+    }
+
     refresh (): void {
         let lang = this.config.store.language
         if (!lang) {

+ 2 - 3
tabby-core/src/theme.new.scss

@@ -29,7 +29,6 @@ app-root {
                 tab-header {
                     border-left: 1px solid transparent;
                     border-right: 1px solid transparent;
-//                     color: $base01;
                     transition: 0.125s ease-out width;
 
                     .index {
@@ -42,8 +41,8 @@ app-root {
                         border: none;
                         transition: 0.25s all;
 
-//                         &:hover { background: $button-hover-bg !important; }
-//                         &:active { background: $button-active-bg !important; }
+                        &:hover { background: var(--theme-bg-more-2) !important; }
+                        &:active { background: var(--theme-bg-more-2) !important; }
                     }
 
                     .progressbar {

+ 1 - 0
tabby-terminal/src/api/baseTerminalTab.component.ts

@@ -195,6 +195,7 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
         this.hostWindow = injector.get(HostWindowService)
         this.translate = injector.get(TranslateService)
         this.multifocus = injector.get(MultifocusService)
+        this.themes = injector.get(ThemesService)
 
         this.logger = this.log.create('baseTerminalTab')
         this.setTitle(this.translate.instant('Terminal'))