ngx-moment
ngx-moment copied to clipboard
local for another lang
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()
})
plz help me
I success to change language (ionic 3).
- do install moment
npm install --save moment
- in module do import in NgModule file:
import { MomentModule } from 'angular2-moment';
import 'moment/locale/vi';
I use this to change the language in angular 4 application:
import * as moment from 'moment';
moment.locale('ru');
I'm using it, but amDateFormat doesn't respect locale....
Agree, it doesn't respect that...
any plans to implement this functionality ?
@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
I think the best solution would be to have moment as a peerDependency, WDYT @wachri ?
With the previous version this hasn't worked, but now this should be the solution :).
released as 3.0.0
@urish Locale still not working properly in 3.1.0. Doesn't seem to change until the next change detection.
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.