У меня есть загрузчик, который получает файл перевода:
export function translateLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, "/i18n/", ".json");
};
Моя структура проекта:
/src/app/app.module.js
/src/i18n/en.json
Когда я запускаю приложение, я получаю это сообщение:
ERROR {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null,
JS: "headers": {}
JS: },
JS: "status": 404,
JS: "statusText": "ERROR",
JS: "url": "/data/data/org.nativescript.App/files/app/i18n/en.json",
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for /data/data/org.nativescript.App/files/app/i18n/en.json: 404 ERROR",
JS: "error": "Not Found"
JS: }
Не удается найти файл по пути /data/data/org.nativescript.App/files/app/i18n/en.json
после компиляции.
Где я должен установить настройки пути?
Мой tsConfig:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"src/*"
]
}
},
"exclude": [
"node_modules",
"platforms"
]
}
Я пробовал:
return new TranslateHttpLoader(http, "../i18n/", ".json");
return new TranslateHttpLoader(http, "./../i18n/", ".json");
return new TranslateHttpLoader(http, "i18n/", ".json");
Теперь я получаю эту ошибку:
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ERROR {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null,
JS: "headers": {}
JS: },
JS: "status": 0,
JS: "statusText": "Unknown Error",
JS: "url": "./assets/i18n/en.json",
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for ./assets/i18n/en.json: 0 Unknown Error",
JS: "error": {
JS: "originalStack": "Error: java.net.MalformedURLException: no protocol: ./assets/i18n/en.json\n at new c (file:///data/data/org.nativescript.App/files/app/vendor.js:1:1700209)\n at file:///data/data/org.nativescript.App/files/app/vendor.js:1:1565607\n at Object.onComplete (file:///data/data/org.nativescript.App/files/app/vendor.js:1:1566741)",
JS: "zoneAwareStack": "Error: java.net.MalformedURLException: no protocol: ./assets/i18n/en.json\n at new c (file:///data/data/org.nativescript.App/files/app/vendor.js:1:1700209)\n at file:///data/data/org.nativescript.App/files/app/vendor.js:1:1565607\n at Object.onComplete (file:///data/data/org.nativescript.App/files/app/vendor.js:1:1...