EddyVerbruggen / nativescript-localize

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

prevent data loss. in strings.xml #88

Open TwistedTamarin opened 4 years ago

TwistedTamarin commented 4 years ago

data loss prevention. (settings, facebookIds etc..)

In your default lang file add:
"protected" : { "exactId": "value" } example: "protected": { "fb_login_protocol_scheme": "xxx", "facebook_app_id": "xxx" }

Everything inside protected. will be added as is. thus keeping important strings inside strings.xml

farfromrefug commented 4 years ago

I am actually needing this to translate keys that are present in preferences.xml. I want to use localize for that too!

brunobg commented 4 years ago

Hey! any plans to merge this?

BHuys commented 4 years ago

This is the perfect fix for a problem I'm having, any plans on merging?

relez commented 3 years ago

Hi there, in the current 5.0.4 version this feature is not working... any updates? Thanks!

farfromrefug commented 3 years ago

@relez in case you want to try I have stopped using this plugin and wrote my own @nativescript-community/l

relez commented 3 years ago

Hey @farfromrefug thanks for the plugin, I switched to your code and its working fine, one quick question, I have this code for Android platform in main.ts file:

import { androidLaunchEventLocalizationHandler } from '@nativescript-community/l';

I have an error that says that there is no such export. Does your plugin works without that code?

Quick question, I am using push notifications and I need to translate the incoming notifications, in the generated files Localizable.strings (iOS for ex) I need to have a variable (%1$@) for the args coming in the notification message (body_loc_args), when that file is created from the i18n files, its rendered with double %% (%%1$@) and it does not work. Is there any way to avoid the generation of that file? Or maybe a way to escape the % and only print 1 instead of 2?

Thanks!

farfromrefug commented 3 years ago

@relez if you have more question please ask on discord. Howeveer i ll answer it as it might help other peoples The function has been renamed to overrideNativeLocale for better understanding.

Now you need to know about the main difference in my plugin. My plugin is much faster if you something like this:

import { loadLocaleJSON } from '@nativescript-community/l';
const localeData = require(`~/i18n/${lang}.json`);
loadLocaleJSON(localeData);

What it does is NOT use the native way to translate keys. In nativescript-localize every single call to localize was going through native to get the translation. It is quite slow especially on android. my plugin do it this way:

Thanks about tit