updated locales

This commit is contained in:
Eugene Pankov
2023-04-10 20:14:21 +02:00
parent c0837febfe
commit 9f050d8e0d
27 changed files with 4894 additions and 4387 deletions

View File

@@ -5,7 +5,7 @@ import { FormsModule } from '@angular/forms'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { NgxFilesizeModule } from 'ngx-filesize'
import { DragDropModule } from '@angular/cdk/drag-drop'
import { TranslateModule, TranslateCompiler, TranslateService } from '@ngx-translate/core'
import { TranslateModule, TranslateCompiler, TranslateService, MissingTranslationHandler } from '@ngx-translate/core'
import { TranslateMessageFormatCompiler, MESSAGE_FORMAT_CONFIG } from 'ngx-translate-messageformat-compiler'
import { AppRootComponent } from './components/appRoot.component'
@@ -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 } from './services/locale.service'
import { CustomMissingTranslationHandler, LocaleService } from './services/locale.service'
import { CommandService } from './services/commands.service'
import { StandardTheme, StandardCompactTheme, PaperTheme, NewTheme } from './theme'
@@ -99,6 +99,10 @@ const PROVIDERS = [
provide: TranslateCompiler,
useFactory: TranslateMessageFormatCompilerFactory,
},
missingTranslationHandler: {
provide: MissingTranslationHandler,
useClass: CustomMissingTranslationHandler,
},
}),
],
declarations: [

View File

@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core'
import { registerLocaleData } from '@angular/common'
import { TranslateService } from '@ngx-translate/core'
import { TranslateService, MissingTranslationHandler } from '@ngx-translate/core'
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler'
import localeENUS from '@angular/common/locales/en'
import localeENGB from '@angular/common/locales/en-GB'
@@ -55,6 +56,19 @@ function flattenMessageFormatTranslation (po: any) {
return translation
}
export class CustomMissingTranslationHandler extends MissingTranslationHandler {
compiler = new TranslateMessageFormatCompiler()
// eslint-disable-next-line @typescript-eslint/ban-types
handle (params: { key: string, translateService: TranslateService, interpolateParams?: Object }): any {
const v = this.compiler.compile(params.key, params.translateService.currentLang)
if (typeof v === 'string') {
return v
}
return v(params.interpolateParams)
}
}
@Injectable({ providedIn: 'root' })
export class LocaleService {
private logger: Logger

View File

@@ -1,37 +1,29 @@
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'
import { Injectable } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { Theme } from './api'
/** @hidden */
@Injectable()
export class StandardTheme extends Theme {
name = this.translate.instant('Standard (legacy)')
name = _('Standard (legacy)')
css = require('./theme.scss')
terminalBackground = '#222a33'
constructor (private translate: TranslateService) {
super()
}
}
/** @hidden */
@Injectable()
export class StandardCompactTheme extends Theme {
name = this.translate.instant('Compact (legacy)')
name = _('Compact (legacy)')
css = require('./theme.compact.scss')
terminalBackground = '#222a33'
macOSWindowButtonsInsetX = 8
macOSWindowButtonsInsetY = 6
constructor (private translate: TranslateService) {
super()
}
}
/** @hidden */
@Injectable()
export class PaperTheme extends Theme {
name = 'Paper (legacy)'
name = _('Paper (legacy)')
css = require('./theme.paper.scss')
terminalBackground = '#f7f1e0'
}
@@ -39,12 +31,8 @@ export class PaperTheme extends Theme {
/** @hidden */
@Injectable({ providedIn: 'root' })
export class NewTheme extends Theme {
name = this.translate.instant('Follow the color scheme')
name = _('Follow the color scheme')
css = require('./theme.new.scss')
terminalBackground = '#f7f1e0'
followsColorScheme = true
constructor (private translate: TranslateService) {
super()
}
}