I have next error:
Request URL:http://localhost:3000/i18n/en.json
Request Method:GET
Status Code:404 Not Found
I'm getting this as well. I'm using the config: new TranslateStaticLoader(http, 'assets/i18n', '.json')
but it seem assets gets "lost" somewhere as it tries to load my files directly from /i18n.
Same thing here, but only when I try to run my tests with Karma i get a 404 not found on /i18n/en.json ...
My dev and prod builds works fine
use this,
bootstrap(App, [
...PROVIDERS,
HTTP_PROVIDERS,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'assets/i18n', '.json'),
deps: [Http]
}),
// use TranslateService here, and not TRANSLATE_PROVIDERS (which will define a default TranslateStaticLoader)
TranslateService
])
and import json files into assets folder.
Edit the .angular-cli.json where we need include the newly created language folder i18n:
"apps": [
{
"assets": [
"i18n"
],
...
Now you can browse the location http://localhost:4200/i18n/en.json and this will be available and issue will be resolved. Try using the following demo:
https://github.com/vinodkumartiwari/angular2-ngx-translate-demo-angular-cli.git
and for production mode .. how to solve it ?
Because it calls localhost
Can anybody help me !
Most helpful comment
Edit the .angular-cli.json where we need include the newly created language folder i18n:
"apps": [
{
"assets": [
"i18n"
],
...
Now you can browse the location http://localhost:4200/i18n/en.json and this will be available and issue will be resolved. Try using the following demo:
https://github.com/vinodkumartiwari/angular2-ngx-translate-demo-angular-cli.git