MOBILE-3708 core: Translate month names in datetime
parent
e427ce6568
commit
81bf906fef
|
@ -161,7 +161,7 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-datetime #notificationPicker hidden [(ngModel)]="notificationTimeText"
|
<ion-datetime #notificationPicker hidden [(ngModel)]="notificationTimeText"
|
||||||
[displayFormat]="notificationFormat" [min]="notificationMin" [max]="notificationMax"
|
[displayFormat]="notificationFormat" [min]="notificationMin" [max]="notificationMax"
|
||||||
doneText]="'core.add' | translate"(ionChange)="addNotificationTime()">
|
[doneText]="'core.add' | translate" (ionChange)="addNotificationTime()" [monthNames]="monthNames">
|
||||||
</ion-datetime>
|
</ion-datetime>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
|
@ -46,6 +46,7 @@ import { AddonCalendarReminderDBRecord } from '../../services/database/calendar'
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { CoreScreen } from '@services/screen';
|
import { CoreScreen } from '@services/screen';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
|
import { CoreLang } from '@services/lang';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays a single calendar event.
|
* Page that displays a single calendar event.
|
||||||
|
@ -87,6 +88,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
||||||
isOnline = false;
|
isOnline = false;
|
||||||
syncIcon = CoreConstants.ICON_LOADING; // Sync icon.
|
syncIcon = CoreConstants.ICON_LOADING; // Sync icon.
|
||||||
isSplitViewOn = false;
|
isSplitViewOn = false;
|
||||||
|
monthNames?: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() protected svComponent: CoreSplitViewComponent,
|
@Optional() protected svComponent: CoreSplitViewComponent,
|
||||||
|
@ -137,6 +139,8 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
protected async asyncConstructor(): Promise<void> {
|
protected async asyncConstructor(): Promise<void> {
|
||||||
if (this.notificationsEnabled) {
|
if (this.notificationsEnabled) {
|
||||||
|
this.monthNames = CoreLang.getMonthNames();
|
||||||
|
|
||||||
this.reminders = await AddonCalendar.getEventReminders(this.eventId);
|
this.reminders = await AddonCalendar.getEventReminders(this.eventId);
|
||||||
this.defaultTime = await AddonCalendar.getDefaultNotificationTime() * 60;
|
this.defaultTime = await AddonCalendar.getDefaultNotificationTime() * 60;
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
||||||
loadUpcoming = false;
|
loadUpcoming = false;
|
||||||
filter: AddonCalendarFilter = {
|
filter: AddonCalendarFilter = {
|
||||||
filtered: false,
|
filtered: false,
|
||||||
courseId: -1,
|
courseId: undefined,
|
||||||
categoryId: undefined,
|
categoryId: undefined,
|
||||||
course: true,
|
course: true,
|
||||||
group: true,
|
group: true,
|
||||||
|
@ -149,7 +149,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
||||||
this.filter = filterData;
|
this.filter = filterData;
|
||||||
|
|
||||||
// Course viewed has changed, check if the user can create events for this course calendar.
|
// Course viewed has changed, check if the user can create events for this course calendar.
|
||||||
this.canCreate = await AddonCalendarHelper.canEditEvents(this.filter['courseId']);
|
this.canCreate = await AddonCalendarHelper.canEditEvents(this.filter.courseId);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -170,12 +170,12 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.route.queryParams.subscribe(() => {
|
this.route.queryParams.subscribe(() => {
|
||||||
this.eventId = CoreNavigator.getRouteNumberParam('eventId');
|
this.eventId = CoreNavigator.getRouteNumberParam('eventId');
|
||||||
this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId') || -1;
|
this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||||
this.year = CoreNavigator.getRouteNumberParam('year');
|
this.year = CoreNavigator.getRouteNumberParam('year');
|
||||||
this.month = CoreNavigator.getRouteNumberParam('month');
|
this.month = CoreNavigator.getRouteNumberParam('month');
|
||||||
this.loadUpcoming = !!CoreNavigator.getRouteBooleanParam('upcoming');
|
this.loadUpcoming = !!CoreNavigator.getRouteBooleanParam('upcoming');
|
||||||
this.showCalendar = !this.loadUpcoming;
|
this.showCalendar = !this.loadUpcoming;
|
||||||
this.filter.filtered = this.filter.courseId > 0;
|
this.filter.filtered = !!this.filter.courseId;
|
||||||
|
|
||||||
if (this.eventId) {
|
if (this.eventId) {
|
||||||
// There is an event to load, open the event in a new state.
|
// There is an event to load, open the event in a new state.
|
||||||
|
|
|
@ -721,7 +721,7 @@ export const AddonCalendarHelper = makeSingleton(AddonCalendarHelperProvider);
|
||||||
*/
|
*/
|
||||||
export type AddonCalendarFilter = {
|
export type AddonCalendarFilter = {
|
||||||
filtered: boolean; // If filter enabled (some filters applied).
|
filtered: boolean; // If filter enabled (some filters applied).
|
||||||
courseId: number; // Course Id to filter.
|
courseId: number | undefined; // Course Id to filter.
|
||||||
categoryId?: number; // Category Id to filter.
|
categoryId?: number; // Category Id to filter.
|
||||||
course: boolean; // Filter to show course events.
|
course: boolean; // Filter to show course events.
|
||||||
group: boolean; // Filter to show group events.
|
group: boolean; // Filter to show group events.
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<span [core-mark-required]="required">{{ field.name }}</span>
|
<span [core-mark-required]="required">{{ field.name }}</span>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-datetime [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="format"
|
<ion-datetime [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="format"
|
||||||
[max]="max" [min]="min">
|
[max]="max" [min]="min" [monthNames]="monthNames">
|
||||||
</ion-datetime>
|
</ion-datetime>
|
||||||
<core-input-errors [control]="form.controls[modelName]"></core-input-errors>
|
<core-input-errors [control]="form.controls[modelName]"></core-input-errors>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { AuthEmailSignupProfileField } from '@features/login/services/login-help
|
||||||
import { CoreUserProfileField } from '@features/user/services/user';
|
import { CoreUserProfileField } from '@features/user/services/user';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { CoreUserProfileFieldBaseComponent } from '@features/user/classes/base-profilefield-component';
|
import { CoreUserProfileFieldBaseComponent } from '@features/user/classes/base-profilefield-component';
|
||||||
|
import { CoreLang } from '@services/lang';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directive to render a datetime user profile field.
|
* Directive to render a datetime user profile field.
|
||||||
|
@ -35,6 +36,7 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
valueNumber = 0;
|
valueNumber = 0;
|
||||||
|
monthNames?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the data when the field is meant to be displayed without editing.
|
* Init the data when the field is meant to be displayed without editing.
|
||||||
|
@ -53,6 +55,8 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
|
||||||
protected initForEdit(field: AuthEmailSignupProfileField): void {
|
protected initForEdit(field: AuthEmailSignupProfileField): void {
|
||||||
super.initForEdit(field);
|
super.initForEdit(field);
|
||||||
|
|
||||||
|
this.monthNames = CoreLang.getMonthNames();
|
||||||
|
|
||||||
// Check if it's only date or it has time too.
|
// Check if it's only date or it has time too.
|
||||||
const hasTime = CoreUtils.isTrueOrOne(field.param3);
|
const hasTime = CoreUtils.isTrueOrOne(field.param3);
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ function buildRoutes(injector: Injector): Routes {
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...conditionalRoutes(mobileRoutes, () => CoreScreen.instance.isMobile),
|
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
|
||||||
...conditionalRoutes(tabletRoutes, () => CoreScreen.instance.isTablet),
|
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,8 +156,6 @@ export class CoreLangProvider {
|
||||||
// Use british english when parent english is loaded.
|
// Use british english when parent english is loaded.
|
||||||
moment.locale(language == 'en' ? 'en-gb' : language);
|
moment.locale(language == 'en' ? 'en-gb' : language);
|
||||||
|
|
||||||
// @todo: Set data for ion-datetime.
|
|
||||||
|
|
||||||
this.currentLanguage = language;
|
this.currentLanguage = language;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -275,6 +273,42 @@ export class CoreLangProvider {
|
||||||
return this.fallbackLanguage;
|
return this.fallbackLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translated month names.
|
||||||
|
*
|
||||||
|
* @return Translated month names.
|
||||||
|
*/
|
||||||
|
getMonthNames(): string[] {
|
||||||
|
return moment.months().map(this.capitalize.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translated month short names.
|
||||||
|
*
|
||||||
|
* @return Translated month short names.
|
||||||
|
*/
|
||||||
|
getMonthShortNames(): string[] {
|
||||||
|
return moment.monthsShort().map(this.capitalize.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translated day names.
|
||||||
|
*
|
||||||
|
* @return Translated day names.
|
||||||
|
*/
|
||||||
|
getDayNames(): string[] {
|
||||||
|
return moment.weekdays().map(this.capitalize.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translated day short names.
|
||||||
|
*
|
||||||
|
* @return Translated day short names.
|
||||||
|
*/
|
||||||
|
getDayShortNames(): string[] {
|
||||||
|
return moment.weekdaysShort().map(this.capitalize.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the full list of translations for a certain language.
|
* Get the full list of translations for a certain language.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue