fix(ssh/settings): formats date value according to locale rules (#10468)

This commit is contained in:
Clem 2025-05-15 21:51:05 +02:00 committed by GitHub
parent af5d3b729b
commit 7ac85a329e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 24 additions and 7 deletions

View File

@ -36,7 +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 } from '../services/locale.service'
export { LocaleService, TabbyFormatedDatePipe } from '../services/locale.service'
export { TranslateService } from '@ngx-translate/core'
export * from '../utils'
export { UTF8Splitter } from '../utfSplitter'

View File

@ -43,7 +43,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 { CustomMissingTranslationHandler, LocaleService } from './services/locale.service'
import { CustomMissingTranslationHandler, LocaleService, TabbyFormatedDatePipe } from './services/locale.service'
import { CommandService } from './services/commands.service'
import { NewTheme } from './theme'
@ -130,6 +130,7 @@ const PROVIDERS = [
DropZoneDirective,
CdkAutoDropGroup,
ProfileIconComponent,
TabbyFormatedDatePipe,
],
exports: [
AppRootComponent,
@ -144,6 +145,7 @@ const PROVIDERS = [
TranslateModule,
CdkAutoDropGroup,
ProfileIconComponent,
TabbyFormatedDatePipe,
],
})
export default class AppModule { // eslint-disable-line @typescript-eslint/no-extraneous-class

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { registerLocaleData } from '@angular/common'
import { Injectable, Pipe, PipeTransform } from '@angular/core'
import { formatDate, registerLocaleData } from '@angular/common'
import { TranslateService, MissingTranslationHandler } from '@ngx-translate/core'
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler'
@ -257,3 +257,15 @@ export class LocaleService {
return this.locale
}
}
@Pipe({
name: 'tabbyDate',
})
export class TabbyFormatedDatePipe implements PipeTransform {
constructor (private locale: LocaleService) {}
transform (date: string): string {
return formatDate(date, 'medium', this.locale.getLocale())
}
}

View File

@ -67,7 +67,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
div {{cfg.name}}
small.text-muted(
translate='Modified on {date}',
[translateParams]='{date: cfg.modified_at|date:"medium"}'
[translateParams]='{date: cfg.modified_at|tabbyDate}'
)
.me-auto
button.btn.btn-link.ms-1(

View File

@ -145,4 +145,5 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
openTabbyWebInfo () {
this.platform.openExternal('https://github.com/Eugeny/tabby-web')
}
}

View File

@ -8,5 +8,5 @@
)
div(*ngFor='let release of releases')
h1 {{release.name}}
.text-muted {{release.version}} / {{release.date|date:'mediumDate'}}
.text-muted {{release.version}} / {{release.date|tabbyDate}}
section([fastHtmlBind]='release.content')

View File

@ -45,4 +45,5 @@ export class ReleaseNotesComponent extends BaseTabComponent {
onScrolled () {
this.loadReleases(this.lastPage + 1)
}
}

View File

@ -61,5 +61,5 @@
div {{item.name}}
.me-auto
.size(*ngIf='!item.isDirectory') {{item.size|filesize}}
.date {{item.modified|date:'medium'}}
.date {{item.modified|tabbyDate}}
.mode {{getModeString(item)}}

View File

@ -273,4 +273,5 @@ export class SFTPPanelComponent {
close (): void {
this.closed.emit()
}
}