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

no effect of moment.locale('ja') #22

Open
hryktrd opened this issue Mar 26, 2020 · 14 comments
Open

no effect of moment.locale('ja') #22

hryktrd opened this issue Mar 26, 2020 · 14 comments

Comments

@hryktrd
Copy link

hryktrd commented Mar 26, 2020

Hi.

I use multiple-date-picker-angular on angular8 project.
I want to change language to japanese day and month letter.

But, I wrote this in component that use date picker

import * as moment from 'moment';
import 'moment/locale/ja';
moment.locale('ja');

it have no effect.

And then, I wrote this in dist/multiple-date-picker.component.js directly,

var moment = require("moment/moment");
moment.locale('ja');

under require moment.
letters of month and day are changed to japanese.

Any other way to change locale?

Thank you.

@anarushka
Copy link

Hi,
Have you tried setting locale at your app level instead of a specific component?

@hryktrd
Copy link
Author

hryktrd commented Apr 30, 2020

I tried setting locale at app.component.ts by receiving your message, but it still don't change to Japanese.
image

my import section in app.component is follows

import { AmplifyService } from 'aws-amplify-angular';
import * as moment from 'moment';
import 'moment/locale/ja';
moment.locale('ja');

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

Thank you.

@balgopal14
Copy link

Hi,
Have slimier problem so i fork and added the locale support feature.

@hryktrd
Copy link
Author

hryktrd commented May 18, 2020

@balgopal14
Hi,
Do you have repository that soluted this problem?
I saw your profile but I couldn't find your repository that forked from this repository.
Do you have it in private repository? If you can share source code, could you show me it?

Thank you.

@hryktrd
Copy link
Author

hryktrd commented May 18, 2020

@balgopal14
Sorry, I was overlooking your pull request.
I'll try to change locale by using your repository.
https://github.com/habilelabs/multiple-date-picker-angular

Thank you.

@balgopal14
Copy link

@hryktrd
Just set the locale parameter in multi-date-picker like this
<multiple-date-picker [locale]="locale">
It will change the language of date picker.

@hryktrd
Copy link
Author

hryktrd commented May 19, 2020

@balgopal14
Thank you, very much.

When I tried it, I could change the locale to ja, but I could change the locale only on the day of the week. Do you know how to change the month locale?

image

@balgopal14
Copy link

Hi @hryktrd,
It changing the locale of month as well in my end. Could you please try to check this on page reload.

@hryktrd
Copy link
Author

hryktrd commented May 22, 2020

Hi. @balgopal14
I tried to clear cache and page reload, but month's locale didn't change to japanese.
Which locale do you use? I'll try to use locale same.

And my usage is follows

<multiple-date-picker
      [(ngModel)]="holidays"
      [fontAwesome]="true"
      [disableDaysBefore]="true"
      [disallowBackPastMonths]="true"
      [sundayFirstDay]="true"
      locale="ja"
    ></multiple-date-picker>

Thank you.

@balgopal14
Copy link

Hi, @hryktrd

image

I used this as a dynamic feature. screenshot is from "sv-SE" locale

@hryktrd
Copy link
Author

hryktrd commented May 25, 2020

Hi, @balgopal14
I tried locale that same as you, but month's locale didn't change...

image

I couldn't under stand that your part of comment 'dynamic feature'. What's mean of it?
And your screenshot looks like different from my screen. I use multiple-date-picker by default design.
Are you using it by any customize?

Thank you.

@hryktrd
Copy link
Author

hryktrd commented Jun 17, 2020

Hi, @balgopal14

I'm sorry to ask you many questions

Do you have any idea to change locale of name of month?

Thank you.

@hryktrd
Copy link
Author

hryktrd commented Jun 17, 2020

Hi, @balgopal14
I solute this problem by fix locale to japanese only.

In your code,

moment.locale(this.locale || 'en-US') //dynamic locale

is not effective to month's format, so I move it to under of

import * as moment from 'moment/moment';

but this.locale is undefined here, so I fix locale to 'ja'.
https://github.com/hryktrd/multiple-date-picker-angular

I'd be happy if the locale could be dynamically set to include the month, but I think a big change is needed.

Thank you.

@balgopal14
Copy link

Hi, @hryktrd
Yes right a big change is needed for month.
I'm not sure why but somehow its working on my end.

Thank you.

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

3 participants