We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I read something about supporting different languages on Android, although it requires xml files and work with IDs instead of Strings. Do you think is still possible with Processing?
Answers
Probably yes, the way described in the article (I haven't read it) or another way... Processing is Java, so i18n in Processing should work the same than in Java.
A lot time ago, I made a sketch using Java i18n capabilities (more or less, I don't recall the details). See if some ideas can be useful to you: http://bazaar.launchpad.net/~philho/+junk/Processing/files/head:/_SmallPrograms/DisplayText/
Thanks PhiLho. Seems a bit more difficult than xml/ids way. I'll check it out
Hello @calsign, I've read you this in an answer, but I might have taken without the context,
So would it be possible to use an xml file, and call the string with R.strings.text... so that have different string.xml inside different "values" languages folders?
Indeed, it should be possible, although Processing might mess around with something that allows it to work. In that particular post, the OP was unable to solve their problem with that method... but that may be for an entirely unrelated reason. I am able to successfully support multiple languages while developing native Android apps... I have not tried a Processing sketch yet. In theory, it should be the same approach.
Please attempt to do this using the approach as explained in the tutorial you linked to and in my quoted comment above. If you encounter any errors, then I can help you through the process...
It may be the case that this is, in fact, impossible... but exporting the sketch and moving to Eclipse would solve the problem (and create other problems). Perhaps I can work on submitting a pull request to the Processing source that would solve the issue if it should arise. Maybe a library would be more user-friendly...
got it, I'll try it soon and comment here, first in Processing, else in Eclipse. thanks in advance for your support calsign!
At first I've tried this,
in res/values/string.xml
and the .pde file
It printed:
2130968576
2130968577
which seems to be some constant values as I've read here, but I'll keep searching and trying.
Yes, this is expected behavior... because the
R
constants are allint
values that are arbitrarily generated (either at run time or at compile time, I'm not entirely sure). You must pass these values to a native function that is capable of retrieving theString
with the given ID. Try this:...where
getResources().getString(int id)
retrieves theString
with the given resource ID.Also, some native Android functions are capable of taking these
int
values for convenience as a way of simplifying things.text()
is not designed to work this way and is, in fact, designed to takeint
values and display them as aString
in a similar fashion toprintln()
. This may be what led to your confusion.you're right!! it worked. this is great.