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

local for another lang #149

Open
hadijahangiri opened this issue Jun 21, 2017 · 12 comments
Open

local for another lang #149

hadijahangiri opened this issue Jun 21, 2017 · 12 comments

Comments

@hadijahangiri
Copy link

hadijahangiri commented Jun 21, 2017

hi, im use ionic 2 and angular2
how use angular2-moment for persian lnaguage in app.module

@NgModule({
    declarations: [declarations()
        , LimitLangDirective
        , AndroidButtonDirective
        , TruncatePipe
    ],
    imports: [
        BrowserModule,
        MomentModule ,
        HttpModule,
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: HttpLoaderFactory,
                deps: [Http]
            }
        }),
      
        IonicStorageModule.forRoot()
    ],
    bootstrap: [IonicApp],
    entryComponents: entryComponents(),
    providers: providers()
})
@hadijahangiri
Copy link
Author

plz help me

@truonghoangnguyen
Copy link

I success to change language (ionic 3).

  1. do install moment npm install --save moment
  2. in module do import in NgModule file:
    import { MomentModule } from 'angular2-moment';
    import 'moment/locale/vi';

@Talalaev
Copy link

I use this to change the language in angular 4 application:

import * as moment  from 'moment';
moment.locale('ru');

@quedicesebas
Copy link

I'm using it, but amDateFormat doesn't respect locale....

@alberthoekstra
Copy link

Agree, it doesn't respect that...

@sebitoelcheater
Copy link

any plans to implement this functionality ?

davemecha pushed a commit to davemecha/ngx-moment that referenced this issue May 7, 2018
When I used the amLocale pipe, I was struggeling with getting the locale loaded. When I did something like

```
{{ myMoment | amLocale:'de' | amDateFormat:'MMMM' }}
```

to thow the month of a date, I always got the english name of the month. After searching the issues, I found this comment urish#149 (comment), what finally helped me. I checked my node_modules that moment was installed and just did the import. I didn't test in my project, if the manual installation of moment.js is necesssary on a clean project.

I think, it would improve the documentation, if this note is added.
@wachri
Copy link

wachri commented May 29, 2018

@urish I sent the PR #187 a while ago. Now with the change of the build process the same problem occurs and it could probably solved in a similar way. Tested only locally, but if you move moment from the dependencies into devDependencies it should not install moment as own dependency so it uses the global one and you can set the local with in a more natural way with

import * as moment  from 'moment';
moment.locale('de');

We fixed it temporarily with with the postinstall in the package.json

scripts: {
...
    "postinstall": "yarn run fix-moment",
    "fix-moment": "rimraf ./node_modules/ngx-moment/node_modules/moment",

Then

import * as moment  from 'moment';
moment.locale('de');

works again

@urish
Copy link
Owner

urish commented Jun 1, 2018

I think the best solution would be to have moment as a peerDependency, WDYT @wachri ?

@wachri
Copy link

wachri commented Jun 1, 2018

With the previous version this hasn't worked, but now this should be the solution :).

@urish
Copy link
Owner

urish commented Jun 2, 2018

released as 3.0.0

urish added a commit that referenced this issue Jun 2, 2018
@thienedits
Copy link

@urish Locale still not working properly in 3.1.0. Doesn't seem to change until the next change detection.

@bnfrnz
Copy link

bnfrnz commented Dec 20, 2018

In 3.3.0 still not working for me. With angular2-moment everything worked. With ngx-moment it does not.

Edit:
Never mind! It was an issue with app-script or webpack. Got it to work. My bad.

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

10 participants