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

Add support for localization #16

Open
mebibou opened this issue Jun 19, 2013 · 2 comments
Open

Add support for localization #16

mebibou opened this issue Jun 19, 2013 · 2 comments

Comments

@mebibou
Copy link

mebibou commented Jun 19, 2013

If used on a device that is not in English metrics, float values are represented by commas and not dots, i.e. 302.2 will appear as 302,2 in French for example.

This causes all call to javascript methods with float values to fail, for example:

android.selection.startTouch(100,00000, 20,00000);

A way to make this work in all cases would be to surround floatvalues by single quotes:

android.selection.startTouch('100,00000', '20,00000');

and parse them to float in the javascript methods (parseFloat(value))

@btate
Copy link
Owner

btate commented Aug 5, 2013

Just pushed a change with this in it. I did the string casting in the javascript so it doesn't matter what you send to it. Give it a shot.

@netomin
Copy link
Contributor

netomin commented Jul 23, 2014

Thank you for this great code! I've been looking for long time for something like this.

I did test your code on a Galaxy S3 phone and on a Nexus 7 tablet and in of both devices the selection didn't work. Nevertheless on the emulator the selection worked out.

Then what I figured out is that both devices had locale French and that what was causing trouble was this kind of strings:

String.format("javascript:android.selection.startTouch(%f, %f);",
xPoint, yPoint);

If you replace all occurrences of String.format with the alternative using the locale US like this:

String.format(Locale.US, "javascript:android.selection.startTouch(%f, %f);",
xPoint, yPoint);

That solved the problem.

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

No branches or pull requests

3 participants