Get Device language error


#1

I am working on ngx-translate, the language is translate well if i specific the language in translateService.use
for example translateService.use(“es”); but when I try to get the device language translateService.use(device.language); then I get the error:
Error: Uncaught (in promise): Error: Could not find module ‘…/…/…/node_modules/tns-core-modules/platform/platform’.

Below is my package.json:

{
“description”: “NativeScript Application”,
“license”: "SEE LICENSE IN ",
“readme”: “NativeScript Application”,
“repository”: “”,
“nativescript”: {
“id”: “org.nativescript.mydrawerng”,
“tns-android”: {
“version”: “4.0.1”
},
“tns-ios”: {
“version”: “4.0.1”
}
},
“scripts”: {
“lint”: “tslint “app/**/*.ts””
},
“dependencies”: {
@angular/animations”: “~6.0.6”,
@angular/cli”: “^6.0.8”,
@angular/common”: “~6.0.6”,
@angular/compiler”: “~6.0.6”,
@angular/core”: “~6.0.6”,
@angular/forms”: “~6.0.6”,
@angular/http”: “~6.0.6”,
@angular/platform-browser”: “~6.0.6”,
@angular/platform-browser-dynamic”: “~6.0.6”,
@angular/router”: “~6.0.6”,
@ngrx/effects”: “^6.0.1”,
@ngrx/store”: “^6.0.1”,
@ngx-translate/core”: “^10.0.2”,
@ngx-translate/http-loader”: “^3.0.1”,
“nativescript-angular”: “^6.0.6”,
“nativescript-drop-down”: “^4.0.1”,
“nativescript-fancyalert”: “^1.2.0”,
“nativescript-theme-core”: “~1.0.4”,
“nativescript-ui-chart”: “^3.7.0”,
“nativescript-ui-sidedrawer”: “~4.0.0”,
“reflect-metadata”: “~0.1.10”,
“rxjs”: “~6.2.1”,
“tns-core-modules”: “4.0.1”,
“zone.js”: “^0.8.26”
},
“devDependencies”: {
@angular/compiler-cli”: “~6.0.7”,
@ngtools/webpack”: “~1.9.4”,
“babel-traverse”: “6.26.0”,
“babel-types”: “6.26.0”,
“babylon”: “6.18.0”,
“clean-webpack-plugin”: “~0.1.19”,
“codelyzer”: “~4.0.2”,
“copy-webpack-plugin”: “~4.3.0”,
“css-loader”: “~0.28.7”,
“extract-text-webpack-plugin”: “~3.0.2”,
“lazy”: “1.0.11”,
“nativescript-dev-sass”: “~1.5.0”,
“nativescript-dev-typescript”: “~0.7.0”,
“nativescript-dev-webpack”: “~0.10.0”,
“nativescript-worker-loader”: “~0.8.1”,
“raw-loader”: “~0.5.1”,
“resolve-url-loader”: “~2.2.1”,
“sass-loader”: “~6.0.6”,
“tslint”: “~5.8.0”,
“typescript”: “~2.7.2”,
“uglifyjs-webpack-plugin”: “~1.1.6”,
“webpack”: “~3.10.0”,
“webpack-bundle-analyzer”: “^2.9.1”,
“webpack-sources”: “~1.1.0”
}
}

Please let me know if i need to do anything else to get the device language for the ngx-translate.

Thanks and Best Regards,


#2

Double check your import statement.


#3

Thanks manojdcoder,

I shorten the auto import from ‘…/…/…/node_modules/tns-core-modules/platform/platform’. to “tns-core-modules/platform/platform”;

Thanks again.

Best Regards