Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calenar Localization #138

Open
dmpour23 opened this issue Feb 8, 2018 · 3 comments
Open

Calenar Localization #138

dmpour23 opened this issue Feb 8, 2018 · 3 comments

Comments

@dmpour23
Copy link

dmpour23 commented Feb 8, 2018

Hi I am trying to Setting localization.

In the calendar weekdays options & monthPickerFormat work. But how can i change the localization on the actual month shown for the month picker ?
i.e FEB 2018
You have the option to set the format but how do you set the localization?
monthFormat | string | 'MMM YYYY' | month title format

Thanks
Dimitri

@ramoncarreras
Copy link

Yes. Same problem here.

I put the following code in my app.module.ts:

import {registerLocaleData} from '@angular/common';
import localeCa from '@angular/common/locales/ca';
import localeEs from '@angular/common/locales/es';
import localeEn from '@angular/common/locales/en';
import localeFr from '@angular/common/locales/fr';

registerLocaleData(localeCa);
registerLocaleData(localeEs);
registerLocaleData(localeEn);
registerLocaleData(localeFr);

@NgModule({
    declarations: [...],
    imports: [
        ...
        CalendarModule,
        ...
    ],
    bootstrap: [...],
    entryComponents: [...],
    providers: [        
        {provide: LOCALE_ID, useValue: "es"} // could be 'es', 'en', 'fr' or 'ca'
    ]
})

Then, if I test with simple localized Angular Pipe...

<p>{{today | date:'fullDate'}}</p>

... the output appeaers localized in spanish (es), BUT MY CALENDAR PICKER IS STILL IN ENGLISH => "February 2018".

@ramoncarreras
Copy link

I think the problem is that you are not using angular date pipe to localize month names. You are using moment format function.

@ramoncarreras
Copy link

This works for me to localize months @dmpour23 :

import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';

import moment from 'moment';
import 'moment/locale/es';

@Component({
    templateUrl: 'app.html'
})
export class TaxApp {
    
    rootPage: string = "HomePage";
    
    constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
        platform.ready().then(() => {
            statusBar.styleDefault();
            splashScreen.hide();
    
            moment.locale("es");            
        });
    }
    
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants