Menu

#5 Various untranslatable, hard-coded strings

2.4
closed
None
2016-03-30
2016-01-31
No

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 45

Additionally 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

Discussion

  • Curtis Gedak

    Curtis Gedak - 2016-01-31

    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.

     
    • Jack Phoenix

      Jack Phoenix - 2016-02-01

      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, Activity is an indirect subclass of [Context](http://developer.android.com/reference/android/content/Context.html), which in turn implements the getResources() method. In Stats.java, the class' constructor is passed an instance of the SolitaireCG class, which extends the Activity class. So I figured you're able to call the getString() method on the existing solitaire variable 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 Context in order to call getResources() on it. So I added a GetContext() method to the SolitaireView class, since an instance of that class is available for the Rules class and its subclasses as mView. This in turn allows calling mView.GetContext().getResources().getString(SOME STRING NAME GOES HERE) in the GetPrettyGameTypeString() method of each of Rules' subclasses.

       

      Last edit: Jack Phoenix 2016-02-01
  • Curtis Gedak

    Curtis Gedak - 2016-02-02

    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.

     
    • Jack Phoenix

      Jack Phoenix - 2016-02-03

      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!

       
  • Curtis Gedak

    Curtis Gedak - 2016-02-03

    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
  • Curtis Gedak

    Curtis Gedak - 2016-02-03
    • Milestone: 1.16 --> 2.4
     
  • Curtis Gedak

    Curtis Gedak - 2016-03-30

    This enhancement was included in the SolitaireCG 2.4 release on March 30, 2016.

     
  • Curtis Gedak

    Curtis Gedak - 2016-03-30
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB