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

Translation file not found #1099

Open
ishaqueahmed-mev opened this issue Jul 15, 2019 · 7 comments
Open

Translation file not found #1099

ishaqueahmed-mev opened this issue Jul 15, 2019 · 7 comments

Comments

@ishaqueahmed-mev
Copy link

ishaqueahmed-mev commented Jul 15, 2019

Hello,

I am trying to use the plugin in nativescript with shared functionality of web and native code in angular 7. I have already used in previous NS projects, but I'm not able to get the proper paths for the jSON files, please help.

This is the required code.
import { HttpClientModule, HttpClient } from "@angular/common/http";
mport { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
....
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}

imports: [
...
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient]
}
})
]

This is the error I am receiving...

CONSOLE ERROR file:///app/vendor.js:51832:24: ERROR {
"headers": {
"normalizedNames": {},
"lazyUpdate": null,
"headers": {}
},
"status": 0,
"statusText": "Unknown Error",
"url": "./assets/i18n/en.json",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for ./assets/i18n/en.json: 0 Unknown Error",
"error": {
"line": 84573,
"column": 38,
"sourceURL": "file:///app/vendor.js",
"originalStack": "ZoneAwareError@file:///app/vendor.js:84573:38\nfile:///app/vendor.js:108252:37\nUIApplicationMain@[native code]\nstart@file:///app/vendor.js:103098:26\nrun@file:///app/vendor.js:103126:10\nbootstrapNativeScriptApp@file:///app/vendor.js:79967:26\nbootstrapApp@file:///app/vendor.js:79868:38\nbootstrapModule@file:///app/vendor.js:79852:26\nfile:///app/bundle.js:2014:144\n./main.ts@file:///app/bundle.js:2019:34\n__webpack_require__@file:///app/bundle.js:752:34\ncheckDeferredModules@file:///app/bundle.js:45:42\nfile:///app/bundle.js:828:38\nanonymous@file:

Been stuck in it for the last 2 hours, don't know what i'm missing here, please help.

@gergelybodor
Copy link

We have a similar issue on ng version 8. The translation files cannot be found, but same configuration works on a version 7 project.

@alroux
Copy link

alroux commented Aug 27, 2019

We have the same issue with V8 and Nativescript

@Schmaga
Copy link

Schmaga commented Sep 23, 2019

For anyone having a similar issue, this might be your solution. Please have a look and check. It solved the problem for me:
#921

@DepickereSven
Copy link

I'm getting the following error

CONSOLE ERROR file:///node_modules/@angular/core/fesm5/core.js:4002:0: ERROR {
"headers": {
"normalizedNames": {},
"lazyUpdate": null,
"headers": {}
},
"status": 404,
"statusText": "ERROR",
"url": "/var/mobile/Containers/Data/Application/07A47D7F-9A3E-4814-A9B7-DF0C72FEA1D7/Library/Application Support/LiveSync/app/assets/i18n/ko-KR.json",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for /var/mobile/Containers/Data/Application/07A47D7F-9A3E-4814-A9B7-DF0C72FEA1D7/Library/Application Support/LiveSync/app/assets/i18n/ko-KR.json: 404 ERROR",
"error": "Not Found"
}

I'm having the following httpLoaderFactory()

import { HttpBackend, HttpClient } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

export function httpLoaderFactory(http: HttpBackend): TranslateHttpLoader {
    return new TranslateHttpLoader(new HttpClient(http));
}

@dudipsh
Copy link

dudipsh commented Feb 24, 2020

any news about this issue?

@dudipsh
Copy link

dudipsh commented Feb 25, 2020

@DepickereSven
try this code

export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpClientModule,
    GraphQLModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: createTranslateLoader,
        deps: [HttpClient]
      }
    })
  ],
  providers: [
    AuthService,
    {provide: HTTP_INTERCEPTORS, useClass: InterceptorService, multi: true},

  ],
  bootstrap: [AppComponent]
})
export class AppModule {
  constructor(
    private translate: TranslateService,

  ) {
    this.translate.setDefaultLang('en');
    translate.use('en');
  }

}

the en.json is in src/assets/i18n

@dodomui
Copy link

dodomui commented Apr 8, 2022

I have this error happens randomly in production in error logging.

Error: Http failure response for ./assets/en.json: 0 Unknown Error

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

7 participants