-import { I18n } from '@ngx-translate/i18n-polyfill'
import { Injectable } from '@angular/core'
+import { PrimeNGConfig } from 'primeng/api'
@Injectable()
export class I18nPrimengCalendarService {
- private readonly calendarLocale: any = {}
- constructor (private i18n: I18n) {
- this.calendarLocale = {
- firstDayOfWeek: 0,
+ constructor (private config: PrimeNGConfig) {
+ this.config.setTranslation({
dayNames: [
- this.i18n('Sunday'),
- this.i18n('Monday'),
- this.i18n('Tuesday'),
- this.i18n('Wednesday'),
- this.i18n('Thursday'),
- this.i18n('Friday'),
- this.i18n('Saturday')
+ $localize`Sunday`,
+ $localize`Monday`,
+ $localize`Tuesday`,
+ $localize`Wednesday`,
+ $localize`Thursday`,
+ $localize`Friday`,
+ $localize`Saturday`
],
dayNamesShort: [
- this.i18n({ value: 'Sun', description: 'Day name short' }),
- this.i18n({ value: 'Mon', description: 'Day name short' }),
- this.i18n({ value: 'Tue', description: 'Day name short' }),
- this.i18n({ value: 'Wed', description: 'Day name short' }),
- this.i18n({ value: 'Thu', description: 'Day name short' }),
- this.i18n({ value: 'Fri', description: 'Day name short' }),
- this.i18n({ value: 'Sat', description: 'Day name short' })
+ $localize`:Sunday short name|Day name short:Sun`,
+ $localize`:Monday short name|Day name short:Mon`,
+ $localize`:Tuesday short name|Day name short:Tue`,
+ $localize`:Wednesday short name|Day name short:Wed`,
+ $localize`:Thursday short name|Day name short:Thu`,
+ $localize`:Friday short name|Day name short:Fri`,
+ $localize`:Saturday short name|Day name short:Sat`
],
dayNamesMin: [
- this.i18n({ value: 'Su', description: 'Day name min' }),
- this.i18n({ value: 'Mo', description: 'Day name min' }),
- this.i18n({ value: 'Tu', description: 'Day name min' }),
- this.i18n({ value: 'We', description: 'Day name min' }),
- this.i18n({ value: 'Th', description: 'Day name min' }),
- this.i18n({ value: 'Fr', description: 'Day name min' }),
- this.i18n({ value: 'Sa', description: 'Day name min' })
+ $localize`:Sunday min name|Day name min:Su`,
+ $localize`:Monday min name|Day name min:Mo`,
+ $localize`:Tuesday min name|Day name min:Tu`,
+ $localize`:Wednesday min name|Day name min:We`,
+ $localize`:Thursday min name|Day name min:Th`,
+ $localize`:Friday min name|Day name min:Fr`,
+ $localize`:Saturday min name|Day name min:Sa`
],
monthNames: [
- this.i18n('January'),
- this.i18n('February'),
- this.i18n('March'),
- this.i18n('April'),
- this.i18n('May'),
- this.i18n('June'),
- this.i18n('July'),
- this.i18n('August'),
- this.i18n('September'),
- this.i18n('October'),
- this.i18n('November'),
- this.i18n('December')
+ $localize`January`,
+ $localize`February`,
+ $localize`March`,
+ $localize`April`,
+ $localize`May`,
+ $localize`June`,
+ $localize`July`,
+ $localize`August`,
+ $localize`September`,
+ $localize`October`,
+ $localize`November`,
+ $localize`December`
],
monthNamesShort: [
- this.i18n({ value: 'Jan', description: 'Month name short' }),
- this.i18n({ value: 'Feb', description: 'Month name short' }),
- this.i18n({ value: 'Mar', description: 'Month name short' }),
- this.i18n({ value: 'Apr', description: 'Month name short' }),
- this.i18n({ value: 'May', description: 'Month name short' }),
- this.i18n({ value: 'Jun', description: 'Month name short' }),
- this.i18n({ value: 'Jul', description: 'Month name short' }),
- this.i18n({ value: 'Aug', description: 'Month name short' }),
- this.i18n({ value: 'Sep', description: 'Month name short' }),
- this.i18n({ value: 'Oct', description: 'Month name short' }),
- this.i18n({ value: 'Nov', description: 'Month name short' }),
- this.i18n({ value: 'Dec', description: 'Month name short' })
+ $localize`:January short name|Month name short:Jan`,
+ $localize`:February short name|Month name short:Feb`,
+ $localize`:March short name|Month name short:Mar`,
+ $localize`:April short name|Month name short:Apr`,
+ $localize`:May short name|Month name short:May`,
+ $localize`:June short name|Month name short:Jun`,
+ $localize`:July short name|Month name short:Jul`,
+ $localize`:August short name|Month name short:Aug`,
+ $localize`:September short name|Month name short:Sep`,
+ $localize`:October short name|Month name short:Oct`,
+ $localize`:November short name|Month name short:Nov`,
+ $localize`:December short name|Month name short:Dec`
],
- today: this.i18n('Today'),
+ today: $localize`Today`,
- clear: this.i18n('Clear')
- }
- }
-
- getCalendarLocale () {
- return this.calendarLocale
+ clear: $localize`Clear`
+ })
}
getTimezone () {
- const gmt = new Date().toString().match(/([A-Z]+[\+-][0-9]+)/)[1]
+ const gmt = new Date().toString().match(/([A-Z]+[+-][0-9]+)/)[1]
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
return `${timezone} - ${gmt}`
}
getDateFormat () {
- return this.i18n({
- value: 'yy-mm-dd ',
- description: 'Date format in this locale.'
- })
+ return $localize`:Date format in this locale.:yy-mm-dd`
}
}