EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

Comptibility with Nativescript 6.0.1 #81

Open lepokle opened 5 years ago

lepokle commented 5 years ago

I've installed nativescript-localized as noted in the installation instructions.

However, localization does not work as expected.

Version information:

✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.0.1 version and is up to date.
✔ Component tns-core-modules has 6.0.1 version and is up to date.
✔ Component tns-android has 6.0.0 version and is up to date.
✔ Component tns-ios has 6.0.1 version and is up to date.

Any help would be appreciated.

schnapzz commented 4 years ago

Hi @lepokle Can you elaborate as to how it isn't working as expected?

cjohn001 commented 4 years ago

Hello together, I have the same issue here. Cannot get the plugin working with 6.0.1. The key string to be translated is returned rather than the translated version of it.

In localize.android.ts the returned identifier from getStringId = 0. I added the plugin to app.module.ts and added the i18n folder to app folder. My en.default.json file looks as follows: { "app.name": "My app", "strHello": "Hello World" }

export function localize(key: string, ...args: string[]): string { let localizedString; try { const identifier = utils.ad.resources.getStringId(encodeKey(key)); localizedString = identifier === 0 ? key : getResources().getString(identifier); } catch (error) { localizedString = key; } return vsprintf(localizedString, args); }

Update, if I move the i18n folder from app to src than the strings are detected and the plugin works as expected

youtpout commented 4 years ago

Update, if I move the i18n folder from app to src than the strings are detected and the plugin works as expected

Thank you it's work

@EddyVerbruggen can you update readme please ?