Various untranslatable, hard-coded strings
Solitaire Card Games for Android™
Brought to you by:
gedakc
First of all, thank you for the awesome app! I was thrilled to see a maintained and recently updated version of Ken Magic's Solitaire app!
That being said, I stumbled upon a few untranslatable strings while trying to translate the app into Finnish.
/src/net/sourceforge/solitaire_cg/Stats.java -- lines 38-41, 52, 54, 56, 61, 65/src/net/sourceforge/solitaire_cg/Help.java -- line 45Additionally all the Rules classes which implement the GetPrettyGameTypeString() method should return a localizable string instead of a hard-coded string. At least the following files' GetPrettyGameTypeString() method needs i18n support for Finnish:
/src/net/sourceforge/solitaire_cg/RulesFortyThieves.java/src/net/sourceforge/solitaire_cg/RulesFreecell.java/src/net/sourceforge/solitaire_cg/RulesKlondike.java
Thanks Jack for your interest in improving SolitaireCG with a Finnish translation.
The challenge is that I do not know how to access the strings.xml resource in files such as Stats.java. If you could help show me how to do this in the code then I could take it from there to ensure the strings are placed in xtrings.xml.
Thanks for the swift reply, Curtis! I spent some time digging into Android's documentation -- both the official docs as well as all the various questions about the subject on StackOverflow -- and I came up with a patch (attached; please excuse the noise caused by trimming trailing whitespace), which is totally untested since I don't have the Android SDK installed (yet) and I'm not very skilled at Java, being mainly a PHP monkey. :-)
According to the official Android docs,
Activityis an indirect subclass of[Context](http://developer.android.com/reference/android/content/Context.html), which in turn implements thegetResources()method. InStats.java, the class' constructor is passed an instance of theSolitaireCGclass, which extends theActivityclass. So I figured you're able to call thegetString()method on the existingsolitairevariable in Stats' constructor.Making the games' names translatable was actually somewhat more difficult, since at first there didn't seem to be an easy way to access any kind of a
Contextin order to callgetResources()on it. So I added aGetContext()method to theSolitaireViewclass, since an instance of that class is available for theRulesclass and its subclasses asmView. This in turn allows callingmView.GetContext().getResources().getString(SOME STRING NAME GOES HERE)in theGetPrettyGameTypeString()method of each ofRules' subclasses.Last edit: Jack Phoenix 2016-02-01
Thank you Jack for researching and implementing a solution to access the strings resources in other files. The patch compiled and worked well. I am not a Java expert and was unsure how to work around the challenge. Your patch has shown me the way. :-)
I have cleaned up the trailing whitespace changes so that only the actual code changes are tracked. I would like to commit your patch and provide credit to you by using the correct author in git. To do this I need the name you would like used, for example "Jack Phoenix", and also an email address.
If you do not wish to have an email address tied to the commit, then I could mention only your name in the commit message.
What would you prefer -- provide a name only, or provide name and email address?
Feel free to email me at gedakc at users.sf.net if you do not wish your desired email address tracked in this ticket.
Glad to hear that it worked! I must say I'm somewhat surprised -- positively, of course! -- since this was pretty much my first time writing a real Java patch. :-)
My email address, which is pretty much all over the place and definitely not private, is jack@countervandalism.net.
Thanks again for handling this so swiftly!
Thank you Jack for this enhancement to enable translation of text strings. Your name and email address has been given credit as the author of the patch.
A modified version of your patch (trailing space changes removed, README updated, commit message added) has been committed to the git master branch for SolitaireCG.
The relevant git commit can be viewed at the following link:
Enable translation of text strings
Last edit: Curtis Gedak 2016-02-03
This enhancement was included in the SolitaireCG 2.4 release on March 30, 2016.