gnome-games r8044 - in trunk/glchess/src: . lib lib/gtkui



Author: rancell
Date: Wed Oct 15 12:35:43 2008
New Revision: 8044
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8044&view=rev

Log:
Added translator comments
Handle unable to import GTK when failed to start program


Modified:
   trunk/glchess/src/glchess.in.in
   trunk/glchess/src/lib/display.py
   trunk/glchess/src/lib/glchess.py
   trunk/glchess/src/lib/gtkui/chessview.py
   trunk/glchess/src/lib/gtkui/dialogs.py
   trunk/glchess/src/lib/gtkui/gtkui.py
   trunk/glchess/src/lib/main.py

Modified: trunk/glchess/src/glchess.in.in
==============================================================================
--- trunk/glchess/src/glchess.in.in	(original)
+++ trunk/glchess/src/glchess.in.in	Wed Oct 15 12:35:43 2008
@@ -15,6 +15,21 @@
 import pygtk
 pygtk.require('2.0')
 
+# Ignore any exceptions writing to stdout using print statements
+class SafeStdout:
+    def __init__(self):
+        self.stdout = sys.stdout
+    
+    def fileno(self):
+        return self.stdout.fileno()
+
+    def write(self, data):
+        try:
+            self.stdout.write(data)
+        except:
+            pass
+sys.stdout = SafeStdout()
+
 # Setup bugbuddy to report unhandled exceptions.
 try: 
     import bugbuddy
@@ -24,19 +39,28 @@
     pass
 
 def report_error():
-    import gtk
     import os.path
     import gettext
     from gettext import gettext as _
-        
+
     gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
     gettext.textdomain('gnome-games')
+    # Translators: This is the title of the dialog displayed if glChess cannot start
     title = _("Chess incorrectly installed")
+    # Translators: This is the contents of the dialog displayed if glChess cannot start
     description = _("""Chess is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
-    dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
-    dialog.format_secondary_text(description)
-    dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
-    dialog.run()
+
+    try:
+        import gtk
+    except ImportError:
+        print title
+        print '-' * len(title)
+        print description
+    else:
+        dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
+        dialog.format_secondary_text(description)
+        dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
+        dialog.run()
     sys.exit(0)
 
 # Chek if we are installed
@@ -49,13 +73,8 @@
 try:
     # Import glChess from pyexecdir or system installation.
     from glchess.glchess import start_game
-except ImportError:
-    # Import of glChess failed. Show error message.
-    report_error()
-    
-try:
     start_game()
 except ImportError:
-    # the game is not entirely installed
+    # Import of glChess failed. Show error message.
     report_error()
 

Modified: trunk/glchess/src/lib/display.py
==============================================================================
--- trunk/glchess/src/lib/display.py	(original)
+++ trunk/glchess/src/lib/display.py	Wed Oct 15 12:35:43 2008
@@ -302,7 +302,7 @@
         """Called by ui.ViewFeedback"""
         self.scene.reshape(width, height)
         self.cairoScene.reshape(width, height)
-        
+
     def select(self, x, y):
         pass
     

Modified: trunk/glchess/src/lib/glchess.py
==============================================================================
--- trunk/glchess/src/lib/glchess.py	(original)
+++ trunk/glchess/src/lib/glchess.py	Wed Oct 15 12:35:43 2008
@@ -1,21 +1,3 @@
-import sys
-
-# Ignore any exceptions writing to stdout using print statements
-class SafeStdout:
-    def __init__(self):
-        self.stdout = sys.stdout
-    
-    def fileno(self):
-        return self.stdout.fileno()
-
-    def write(self, data):
-        try:
-            self.stdout.write(data)
-        except:
-            pass
-
-sys.stdout = SafeStdout()
-
 import main
 def start_game ():
     app = main.Application()

Modified: trunk/glchess/src/lib/gtkui/chessview.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/chessview.py	(original)
+++ trunk/glchess/src/lib/gtkui/chessview.py	Wed Oct 15 12:35:43 2008
@@ -14,11 +14,13 @@
 try:
     import OpenGL.GL
 except:
+    # Translators: This message is displayed when 3D mode is not available due to no Python OpenGL libraries
     openGLErrors.append(_('No Python OpenGL support'))
 try:
     import gtk.gtkgl
     import gtk.gdkgl
 except:
+    # Translators: This message is displayed when 3D mode is not available due to no Python GTKGLExt libraries
     openGLErrors.append(_('No Python GTKGLExt support'))
 else:
     display_mode = (gtk.gdkgl.MODE_RGB | gtk.gdkgl.MODE_DEPTH | gtk.gdkgl.MODE_DOUBLE)
@@ -29,6 +31,7 @@
         try:
             glConfig = gtk.gdkgl.Config(mode = display_mode)
         except gtk.gdkgl.NoMatches:
+            # Translators: This message is displayed when 3D mode is not available due to their 3D drivers not being able to provide a suitable display mode
             openGLErrors.append(_('OpenGL libraries do not support required display mode'))
 haveGLSupport = len(openGLErrors) == 0
 
@@ -461,35 +464,48 @@
             self.ui._updateViewButtons()
 
     def endGame(self, game):
+        # Translators: This message is displayed when a player wins. The %s is substituted with the winning player's name
+        format = _('%s wins')
+        
         # If game completed show this in the GUI
         if game.result is glchess.game.RESULT_WHITE_WINS:
-            title = _('%s wins') % game.getWhite().getName()
+            title = format % game.getWhite().getName()
         elif game.result is glchess.game.RESULT_BLACK_WINS:
-            title = _('%s wins') % game.getBlack().getName()
+            title = format % game.getBlack().getName()
         else:
+            # Translators: This message is displayed when a game is drawn
             title = _('Game is drawn')
 
         description = ''
         if game.rule is glchess.game.RULE_CHECKMATE:
+            # Translators: This message is displayed when the game ends due to a player being checkmated
             description = _('Opponent is in check and cannot move (checkmate)')
         elif game.rule is glchess.game.RULE_STALEMATE:
+            # Translators: This message is displayed when the game terminates due to a stalemate
             description = _('Opponent cannot move (stalemate)')
         elif game.rule is glchess.game.RULE_FIFTY_MOVES:
+            # Translators: This message is displayed when the game is drawn due to the fifty move rule
             description = _('No piece has been taken or pawn moved in the last fifty moves')
         elif game.rule is glchess.game.RULE_TIMEOUT:
+            # Translators: This message is displayed when the game ends due to one player's clock stopping
             description = _('Opponent has run out of time')
         elif game.rule is glchess.game.RULE_THREE_FOLD_REPETITION:
+            # Translators: This message is displayed when the game is drawn due to the three-fold-repitition rule
             description = _('The same board state has occured three times (three fold repetition)')
         elif game.rule is glchess.game.RULE_INSUFFICIENT_MATERIAL:
+            # Translators: This message is displayed when the game is drawn due to the insufficient material rule
             description = _('Neither player can cause checkmate (insufficient material)')
         elif game.rule is glchess.game.RULE_RESIGN:
             if game.result is glchess.game.RESULT_WHITE_WINS:
+                # Translators: This message is displayed when the game ends due to the black player resigning
                 description = _('The black player has resigned')
             elif game.result is glchess.game.RESULT_BLACK_WINS:
+                # Translators: This message is displayed when the game ends due to the white player resigning
                 description = _('The white player has resigned')
             else:
                 assert(False)
         elif game.rule is glchess.game.RULE_DEATH:
+            # Translators: This message is displayed when the game ends due to a player dying
             description = _('One of the players has died')
 
         self.gameResult = (title, description)

Modified: trunk/glchess/src/lib/gtkui/dialogs.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/dialogs.py	(original)
+++ trunk/glchess/src/lib/gtkui/dialogs.py	Wed Oct 15 12:35:43 2008
@@ -120,6 +120,7 @@
             
         # Create model for game time
         defaultTime = glchess.config.get('new_game_dialog/move_time')
+        # Translators: This is one of the options game duration combo box in the new game dialog
         times = [(_('Unlimited'),       0),
                  (_('One minute'),     60),
                  (_('Five minutes'),  300),
@@ -238,6 +239,7 @@
             
             # Change title for loaded games
             if g.path is not None:
+                # Translators: This is the title of the dialog when continuing a loaded game
                 self.window.set_title(_('Configure loaded game (%i moves)') % len(g.moves))
 
         # Display warning if missing the AIs
@@ -296,7 +298,7 @@
         if self.__customName:
             name = self.__gui.get_widget('game_name_entry').get_text()
             if len(name) == 0:
-                # Next time the something changes generate a name
+                # Next time something changes generate a name
                 self.__customName = False
                 ready = False
 
@@ -304,6 +306,7 @@
         else:
             whiteName = self.__getComboData(self.__gui.get_widget('white_type_combo'), 2)
             blackName = self.__getComboData(self.__gui.get_widget('black_type_combo'), 2)
+            # Translators: This is the default name for a new game. %(white) and %(black) are substituted for the names of the white and black players.
             format = _('%(white)s versus %(black)s')
             self.__gui.get_widget('game_name_entry').set_text(format % {'white': whiteName, 'black': blackName})
 
@@ -327,12 +330,14 @@
         # Get the players
         game.white.type  = self.__getComboData(self.__gui.get_widget('white_type_combo'), 0)
         if game.white.type == '':
+            # Translators: This is the default name for the white player
             game.white.name = _('White')
         else:
             game.white.name = self.__getComboData(self.__gui.get_widget('white_type_combo'), 2)
         game.white.level = self.__getComboData(self.__gui.get_widget('white_difficulty_combo'), 0)
         game.black.type  = self.__getComboData(self.__gui.get_widget('black_type_combo'), 0)
         if game.black.type == '':
+            # Translators: This is the default name for the black player
             game.black.name = _('Black')
         else:
             game.black.name = self.__getComboData(self.__gui.get_widget('black_type_combo'), 2)
@@ -442,6 +447,7 @@
 
             fileName = self.__gui.get_widget('filechooserwidget').get_filename()
             if fileName is None:
+                # Translators: This message is displayed in the load dialog when no file is selected
                 error = _('Please select a file to load')
             else:
                 error = self.__mainUI.feedback.loadGame(fileName, responseId == gtk.RESPONSE_YES)

Modified: trunk/glchess/src/lib/gtkui/gtkui.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/gtkui.py	(original)
+++ trunk/glchess/src/lib/gtkui/gtkui.py	Wed Oct 15 12:35:43 2008
@@ -462,7 +462,9 @@
         dialog = gtk.MessageDialog(flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                    type = gtk.MESSAGE_WARNING,
                                    message_format = title)
-        dialog.format_secondary_text(_("If you don't save the changes to this game will be permanently lost")
+        # Translators: This text is displayed in a dialog asking the user to save the current game
+        dialog.format_secondary_text("If you don't save the changes to this game will be permanently lost")
+        # Translators: This is the button text in the save game dialog to decline to save the game
         dialog.add_button(_('Close _without saving'), gtk.RESPONSE_OK)
         dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
         dialog.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
@@ -577,8 +579,10 @@
         # Enable/disable OpenGL rendering
         elif name == 'show_3d':            
             if value and not chessview.haveGLSupport:
+                # Translators: This is the title of the dialog that is displayed when a user tries to enable 3D without the required libraries
                 title = _('Unable to enable 3D mode')
                 errors = '\n'.join(chessview.openGLErrors)
+                # Translators: This is displayed in a dialog when a user tries to enable 3D without the required libraries. %(error)s will be replaced with a list of reasons why 3D is not available.
                 description = _("""You are unable to play in 3D mode due to the following problems:
 %(errors)s
 
@@ -830,12 +834,18 @@
         """Gtk+ callback"""
         if self.view.feedback.claimDraw():
             return
+        
+        # Translators: This is the title of the dialog that is displayed when a user requests a draw but one is not available
+        title = _("Unable to claim draw")
+        # Translators: This is the message that is displayed in a dialog when a user requests a draw but one is not available
+        message = _("""You may claim a draw when:
+a) The board has been in the same state three times (Three fold repitition)
+b) Fifty moves have occured where no pawn has moved and no piece has been captured (50 move rule)""")
+        
         dialog = gtk.MessageDialog(flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                    type = gtk.MESSAGE_WARNING,
-                                   message_format = _("Unable to claim draw"))
-        dialog.format_secondary_text(_("""You may claim a draw when:
-a) The board has been in the same state three times (Three fold repetition)
-b) Fifty moves have occured where no pawn has moved and no piece has been captured (50 move rule)"""))
+                                   message_format = title)
+        dialog.format_secondary_text(message)
         dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)
         dialog.run()
         dialog.destroy()

Modified: trunk/glchess/src/lib/main.py
==============================================================================
--- trunk/glchess/src/lib/main.py	(original)
+++ trunk/glchess/src/lib/main.py	Wed Oct 15 12:35:43 2008
@@ -442,7 +442,9 @@
         
         self.history = history.GameHistory()
         
-        self.logger = self.ui.controller.addLogWindow(_('Application Log'), '', '')
+        # Translators: This is the name of the log that displays application events
+        title = _('Application Log')
+        self.logger = self.ui.controller.addLogWindow(title, '', '')
 
     def addAIProfile(self, profile):
         """Add a new AI profile into glChess.
@@ -687,6 +689,8 @@
             self.logger.addLine('loaded in %f seconds' % (time.time() - s))
 
         else:
+            # Translators: This is the text displayed on the command-line if an unknown argument is passed
+            # FIXME: Should be in a dialog
             print _('Usage: %s [game]') % sys.argv[0]
             sys.exit(0)
 
@@ -697,8 +701,11 @@
                     aiName = p.name
                     break
             black = (aiName, 'easy')
-            name = _('Human versus %s') % aiName
-            g = self.addLocalGame(name, _('White'), None, _('Black'), black)
+            # Translators: This is the name of a human versus AI game. The %s is replaced with the name of the AI player
+            gameName = _('Human versus %s') % aiName
+            whiteName =  _('White')
+            blackName = _('Black')
+            g = self.addLocalGame(gameName, whiteName, None, blackName, black)
             g.inHistory = True
             g.start()
 
@@ -706,8 +713,9 @@
         try:
             self.ui.controller.run()
         except:
-            print _('glChess has crashed. Please report this bug to http://bugzilla.gnome.org')
-            print _('Debug output:')
+            # FIXME: Isn't this done by bug-buddy?
+            print _("""glChess has crashed. Please report this bug to http://bugzilla.gnome.org
+Debug output:""")
             print traceback.format_exc()
             self.quit()
             sys.exit(1)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]