ngx-moment icon indicating copy to clipboard operation
ngx-moment copied to clipboard

local for another lang

Open hadijahangiri opened this issue 7 years ago • 12 comments

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 avatar Jun 21 '17 13:06 hadijahangiri

plz help me

hadijahangiri avatar Jun 30 '17 12:06 hadijahangiri

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';

truonghoangnguyen avatar Jul 13 '17 08:07 truonghoangnguyen

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

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

Talalaev avatar Jul 13 '17 10:07 Talalaev

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

quedicesebas avatar Aug 18 '17 19:08 quedicesebas

Agree, it doesn't respect that...

alberthoekstra avatar Aug 22 '17 09:08 alberthoekstra

any plans to implement this functionality ?

sebitoelcheater avatar Apr 19 '18 23:04 sebitoelcheater

@urish I sent the PR https://github.com/urish/ngx-moment/pull/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

wachri avatar May 29 '18 12:05 wachri

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

urish avatar Jun 01 '18 08:06 urish

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

wachri avatar Jun 01 '18 11:06 wachri

released as 3.0.0

urish avatar Jun 02 '18 20:06 urish

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

thienedits avatar Sep 04 '18 07:09 thienedits

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.

bnfrnz avatar Dec 20 '18 04:12 bnfrnz