Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent data loss. in strings.xml #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TwistedTamarin
Copy link

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

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
Missed to delete the first encodedI18nEntries.set line. 
Also added ios plist filter.
@farfromrefug
Copy link

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

@brunobg
Copy link

brunobg commented Apr 6, 2020

Hey! any plans to merge this?

@BHuys
Copy link

BHuys commented May 20, 2020

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

@relez
Copy link

relez commented Mar 23, 2021

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

@farfromrefug
Copy link

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

@relez
Copy link

relez commented Mar 24, 2021

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
Copy link

@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:

  • if a locale was loaded through loadLocaleJSON simply loaded from JS memory
  • if not goes the native way.

Thanks about tit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants