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

Localizing hardcoded messages #339

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

Localizing hardcoded messages #339

wants to merge 4 commits into from

Conversation

kohlia
Copy link

@kohlia kohlia commented Sep 10, 2018

Platforms affected

iOS

What does this PR do?

Localizes messages hardcoded

What testing has been done on this change?

Works on Cordova based application

Checklist

  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

@kohlia
Copy link
Author

kohlia commented Sep 17, 2018

Please merge this

@@ -100,6 +100,7 @@
<clobbers target="CameraPopoverHandle" />
</js-module>

<resource-file src="src/ios/Camera.strings" target="en.lproj/Camera.strings" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about iOS. What does target="en.lproj/Camera.strings" mean here?

Copy link
Author

@kohlia kohlia Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will copy the hardcoded message file Camera.strings into a language location en.lproj as Camera.strings and we can load the message from this file in the code at runtime

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so en.lproj is a magic thing that the project will know about and load en.lproj/Camera.strings without any additional configuration?

Should the file maybe be called cordova-plugin-camera.strings?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The en.lproj or fr.lproj or ar.lproj etc are understood by app to load corresponding language files
You are free to name the strings file just update the plugin.xml accordingly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was really more a question - to make sure developers know what the file is from and for. You created the PR, so you can decide and adapt or not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it like this then I have no issues

@@ -0,0 +1,3 @@
"camera.prohibited" = "Access to the camera has been prohibited; please enable it in the Settings app to continue.";
"camera.ok" = "Settings";
"camera.settings" = "OK";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These last two strings seem to be swapped

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry about that should I update ?

Copy link
Member

@janpio janpio Sep 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we of course can't merge obviously broken code and files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@oliversalzburg
Copy link

We use https://github.com/fairmanager-cordova/plugin-localization-strings for this. It applies pretty much universally to all native localizable strings. I like a centralized solution for this problem. Might be worth a look.

@kohlia
Copy link
Author

kohlia commented Sep 17, 2018

We use https://github.com/fairmanager-cordova/plugin-localization-strings for this. It applies pretty much universally to all native localizable strings. I like a centralized solution for this problem. Might be worth a look.

I gather the values in InfoPlist.strings cannot be accessed in code, correct me if I am wrong

@oliversalzburg
Copy link

@kohlia I'm not sure I understand the question correctly. The plugin will create localization projects from the JSON configuration. The remaining process is pretty much transparent.

If you need a localized string from ObjC, this is how to do it: https://github.com/fairmanager-cordova/plugin-barcodescanner/commit/73d0f497b242627b33dcd6fbfb32d0d14501b100

@kohlia
Copy link
Author

kohlia commented Sep 17, 2018

@oliversalzburg makes sense so now I need to update the code to fetch from InfoPlist.strings but this will add dependency on this https://github.com/fairmanager-cordova/plugin-localization-strings plugin

@oliversalzburg
Copy link

@kohlia I'm sorry, I didn't mean to suggest to depend on that plugin. I wanted to merely point out an existing solution in this area. This patch looks like it tries to achieve similar things and this approach might even conflict with existing solutions.

Ideally, all solutions play nice together. Sadly, I can't fully evaluate the situation at the moment.

@kohlia
Copy link
Author

kohlia commented Sep 18, 2018

So what now?

@janpio
Copy link
Member

janpio commented Sep 18, 2018

Now you can decide if this has any impact on your PR and change something or not.
And then some maintainer will maybe review your PR and decide if it can and should be merged or not.

@kohlia
Copy link
Author

kohlia commented Sep 18, 2018

Now you can decide if this has any impact on your PR and change something or not.
And then some maintainer will maybe review your PR and decide if it can and should be merged or not.

This still does not impact the PR as dependency on another plugin should not be created. I feel this solution works fine

@janpio
Copy link
Member

janpio commented Sep 18, 2018

Nobody told you to include the other plugin, @oliversalzburg just mentioned it so we all can consider if these changes might make this plugin incompatible to that other plugin that solves a similar problem for existing users.

@kohlia
Copy link
Author

kohlia commented Sep 18, 2018

Its up to the maintainers now.

@kohlia
Copy link
Author

kohlia commented Sep 27, 2018

Please merge the change

@janpio
Copy link
Member

janpio commented Oct 1, 2018

Hey, I just fixed the problem that caused Android tests to fail in master. Could you rebase this PR please? This should get rid of the Android failures and possibly fix all test failures for this PR.

@janpio
Copy link
Member

janpio commented Oct 3, 2018

Closing and re-opening to trigger a new CI/test run with new PR merge.

@janpio janpio closed this Oct 3, 2018
@janpio janpio reopened this Oct 3, 2018
@jcesarmobile
Copy link
Member

Strings are already localizable as they are NSLocalizedString, I don't see any improvement on changing them to NSLocalizedStringFromTable

@kohlia
Copy link
Author

kohlia commented Nov 26, 2018

That is done to specify language file, so as to keep if separate from overlapping any application language files

@oliversalzburg
Copy link

I'd prefer if the literals were prefixed (as they already are in this patch) and just be left in the main table. Creating multiple tables might be the cleaner approach, but it's also a new solution in the entire environment and might require more thought in general.

@guirip
Copy link

guirip commented Apr 16, 2020

Hello there 👋
Any chance to see the conflict resolved? We need localization for this message but it doesn't seem possible today.

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

Successfully merging this pull request may close these issues.

6 participants