diff --git a/src/addon/calendar/pages/event/event.ts b/src/addon/calendar/pages/event/event.ts index 568eac629..0f7fed557 100644 --- a/src/addon/calendar/pages/event/event.ts +++ b/src/addon/calendar/pages/event/event.ts @@ -73,7 +73,7 @@ export class AddonCalendarEventPage { }); // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them. - this.notificationFormat = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedatetimeshort')) + this.notificationFormat = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedatetime')) .replace(/[\[\]]/g, ''); } } diff --git a/src/addon/mod/data/fields/date/component/date.ts b/src/addon/mod/data/fields/date/component/date.ts index 5b17bf4a5..187a6fbba 100644 --- a/src/addon/mod/data/fields/date/component/date.ts +++ b/src/addon/mod/data/fields/date/component/date.ts @@ -43,7 +43,7 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo let val; // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them. - this.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedatefullshort')) + this.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.strftimedate')) .replace(/[\[\]]/g, ''); if (this.mode == 'search') { diff --git a/src/addon/userprofilefield/datetime/component/datetime.ts b/src/addon/userprofilefield/datetime/component/datetime.ts index c43a61bc0..1d9e9ea03 100644 --- a/src/addon/userprofilefield/datetime/component/datetime.ts +++ b/src/addon/userprofilefield/datetime/component/datetime.ts @@ -49,7 +49,7 @@ export class AddonUserProfileFieldDatetimeComponent implements OnInit { // Calculate format to use. ion-datetime doesn't support escaping characters ([]), so we remove them. field.format = this.timeUtils.convertPHPToMoment(this.translate.instant('core.' + - (hasTime ? 'strftimedatetimeshort' : 'strftimedatefullshort'))).replace(/[\[\]]/g, ''); + (hasTime ? 'strftimedatetime' : 'strftimedate'))).replace(/[\[\]]/g, ''); // Check min value. if (field.param1) { diff --git a/src/providers/lang.ts b/src/providers/lang.ts index 04f8283ee..68463d4e3 100644 --- a/src/providers/lang.ts +++ b/src/providers/lang.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import * as moment from 'moment'; import { Globalization } from '@ionic-native/globalization'; -import { Platform } from 'ionic-angular'; +import { Platform, Config } from 'ionic-angular'; import { CoreConfigProvider } from './config'; import { CoreConfigConstants } from '../configconstants'; @@ -33,7 +33,7 @@ export class CoreLangProvider { protected sitePluginsStrings = {}; // Strings defined by site plugins. constructor(private translate: TranslateService, private configProvider: CoreConfigProvider, platform: Platform, - private globalization: Globalization) { + private globalization: Globalization, private config: Config) { // Set fallback language and language to use until the app determines the right language to use. translate.setDefaultLang(this.fallbackLanguage); translate.use(this.defaultLanguage); @@ -86,6 +86,17 @@ export class CoreLangProvider { } } + /** + * Capitalize a string (make the first letter uppercase). + * We cannot use a function from text utils because it would cause a circular dependency. + * + * @param {string} value String to capitalize. + * @return {string} Capitalized string. + */ + protected capitalize(value: string): string { + return value.charAt(0).toUpperCase() + value.slice(1); + } + /** * Change current language. * @@ -142,6 +153,13 @@ export class CoreLangProvider { // Use british english when parent english is loaded. moment.locale(language == 'en' ? 'en-gb' : language); + + // Set data for ion-datetime. + this.config.set('monthNames', moment.months().map(this.capitalize.bind(this))); + this.config.set('monthShortNames', moment.monthsShort().map(this.capitalize.bind(this))); + this.config.set('dayNames', moment.weekdays().map(this.capitalize.bind(this))); + this.config.set('dayShortNames', moment.weekdaysShort().map(this.capitalize.bind(this))); + this.currentLanguage = language; return Promise.all(promises).finally(() => {