Mayank Shrivastava
Mayank Shrivastava

Reputation: 362

Angular translate giving key when upgraded to WKWebview for localization

We are working on ionic application which support ionic-v1. For translation we use $translate. The issue is when using $translate.use() and $translate.instant() its giving key instead of proper value.

Note: This issue we are facing after we upgrade the cordova-iOS to 6.0 from UIwebview to WKWebview, once downgrade the cordova-iOS back to 5.0 its working as expected and all are scripts are in scripts/locales folder.

Below was the working code.:

en.js // locale file

{
 "APP_NAME_LABEL": "My app name",
}

script.js //controller js file

$translate.use('en').then(function (translation) {
        $scope.viewTitle =$translate.instant('APP_NAME_LABEL');
});

Expectation: should give value 'My app name' of "APP_NAME_LABEL" key from locale file. Reality : giving key "APP_NAME_LABEL" instead of value

Could anyone let me know what to do to resolve it.

Upvotes: 0

Views: 102

Answers (1)

tschleuss
tschleuss

Reputation: 56

I found out that's a problem with CORS/Security from the new WKWebView. TO solve that, you should define a schema and a hostname in your config.xml file.

I solved the issue adding this to the config.xml file

<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />

Upvotes: 0

Related Questions