Core: How to publish json translation files?

Created on 13 May 2016  路  5Comments  路  Source: ngx-translate/core

I have next error:

Request URL:http://localhost:3000/i18n/en.json
Request Method:GET
Status Code:404 Not Found

questiosupport

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

All 5 comments

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 !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbaumi picture rbaumi  路  4Comments

dankerk picture dankerk  路  3Comments

Snap252 picture Snap252  路  3Comments

guysan picture guysan  路  4Comments

madoublet picture madoublet  路  3Comments