diff --git a/PySudoku.py b/PySudoku.py index 8258c68..51c8e6e 100644 --- a/PySudoku.py +++ b/PySudoku.py @@ -6,7 +6,10 @@ PySudoku v0.2 by Adrien MALINGREY Sudoku game assistant Tested on Windows 10 with Python 3.6.3 and Linux Mint 18 with Python 3.5.1 """ + try: + import gettext + from sys import argv, exit from tkinter import * from tkinter import ttk from tkinter.filedialog import askopenfilename, asksaveasfilename @@ -16,98 +19,106 @@ try: from os.path import basename, dirname, exists from random import sample, shuffle from webbrowser import open as open_web_browser - from sys import argv, exit from string import digits except ImportError as e: exit(e.msg) +# Translation +try: + gettext.find('PySudoku') + translator = gettext.translation('PySudoku', localedir='locale') +except FileNotFoundError: + gettext.install('Translation not found') +else: + translator.install('PySudoku') + # Labels -APP_TITLE = "PySudoku" +APP_TITLE = _("PySudoku") -GRID_LABEL = "Grid" -GENERATE_LABEL = "Generate..." -CREATE_LABEL = "Create" -EDIT_LABEL = "Edit" -VALIDATE_LABEL = "Validate" -SOLVE_LABEL = "Solve" +GRID_LABEL = _("Grid") +GENERATE_LABEL = _("Generate...") +CREATE_LABEL = _("Create") +EDIT_LABEL = _("Edit") +VALIDATE_LABEL = _("Validate") +SOLVE_LABEL = _("Solve") -GAME_LABEL = "Game" -LOAD_LABEL = "Load..." -SAVE_LABEL = "Save..." -RESTART_LABEL = "Restart..." +GAME_LABEL = _("Game") +LOAD_LABEL = _("Load...") +SAVE_LABEL = _("Save...") +RESTART_LABEL = _("Restart...") -VIEW_LABEL = "View" -THEME_LABEL = "Theme" -SHOW_TIPS_LABEL = "Show tips" -SHOW_CONFLICTS_LABEL = "Show conflicts" +VIEW_LABEL = _("View") +THEME_LABEL = _("Theme") +SHOW_TIPS_LABEL = _("Show tips") +SHOW_CONFLICTS_LABEL = _("Show conflicts") -HELP_LABEL = "?" -WIKI_LABEL = "Wikipedia" -ABOUT_LABEL = "About..." +HELP_LABEL = _("?") +WIKI_LABEL = _("Wikipedia") +ABOUT_LABEL = _("About...") -GENERATE_PROGRESS_BOX_TITLE = "Grid generation" -GENERATE_PROGRESS_BOX_TEXT = "Generating a new grid..." -CLUES_DELETING_PROGRESS_BOX_TEXT = "Deleting clues..." -CANCEL_AUTO_CREATE_BUTTON_TEXT = "Stop" +GENERATE_PROGRESS_BOX_TITLE = _("Grid generation") +GENERATE_PROGRESS_BOX_TEXT = _("Generating a new grid...") +CLUES_DELETING_PROGRESS_BOX_TEXT = _("Deleting clues...") +CANCEL_AUTO_CREATE_BUTTON_TEXT = _("Stop") -VALIDATION_PROGRESS_BOX_TITLE = "Grid validation" -VALIDATION_PROGRESS_BOX_TEXT = "Checking if grid has a unique solution..." +VALIDATION_PROGRESS_BOX_TITLE = _("Grid validation") +VALIDATION_PROGRESS_BOX_TEXT = _("Checking if grid has a solution...") -NO_SOLUTION_MESSAGE_BOX_TITLE = "Can't solve grid" +NO_SOLUTION_MESSAGE_BOX_TITLE = _("Can't solve grid") NO_SOLUTION_MESSAGE_BOX_TEXT = ( - "Some boxes have no solution. " - "Please correct it." + _("Some boxes have no solution. " + "Please correct it.") ) -NO_OTHER_SOLUTION_PROGESS_BOX_TEXT = "Checking if grid has other solutions..." +NO_OTHER_SOLUTION_PROGESS_BOX_TEXT =_( "Checking if grid has other solutions...") -INCORRECT_GRID_MESSAGE_BOX_TITLE = "Incorrect grid" -SEVERAL_SOLUTIONS_MESSAGE_BOX_TEXT = "The grid has several solutions." +INCORRECT_GRID_MESSAGE_BOX_TITLE = _("Incorrect grid") +SEVERAL_SOLUTIONS_MESSAGE_BOX_TEXT = _("The grid has several solutions.") CONFLICTS_MESSAGE_BOX_TEXT = ( - "Some boxes from the same row, column or region " - "have same digit. Please correct them." + _("Some boxes from the same row, column or region " + "have same digit. Please correct them.") ) -SOLVING_PROGRESS_BOX_TITLE = "Solving grid" -CALCULATING_SURE_DIGITS_TEXT = "Calculating sure digits..." -TESTS_PROGRESS_BOX_TEXT = "Test: {} on {}" +SOLVING_PROGRESS_BOX_TITLE = _("Solving grid") +CALCULATING_SURE_DIGITS_TEXT = _("Calculating sure digits...") +TESTS_PROGRESS_BOX_TEXT = _("Test: {} on {}") NO_SOLUTION_EXCEPTION = ( - "There are some error. " - "Please correct them to solve the grid." + _("There are some error. " + "Please correct them to solve the grid.") ) -CANCEL_EXCEPTION = "Cancelled" +CANCEL_EXCEPTION = _("Cancelled") -SOLVED_GRID_MESSAGE_BOX_TITLE = "Congratulations!" -SOLVED_GRID_MESSAGE_BOX_TEXT = "The grid is solved." +SOLVED_GRID_MESSAGE_BOX_TITLE = _("Congratulations!") +SOLVED_GRID_MESSAGE_BOX_TEXT = _("The grid is solved.") -NB_CLUES_MESSAGE_BOX_TITLE = "Generate a new grid" -NB_CLUES_INPUT_LABEL = "Please enter minimum number of clues:" -HARDER_LABEL = "← harder" -EASIER_LABEL = "easier →" -CANCEL_BUTTON_TEXT = "Cancel" -OK_BUTTON_TEXT = "OK" +NB_CLUES_MESSAGE_BOX_TITLE = _("Generate a new grid") +NB_CLUES_INPUT_LABEL = _("Please enter minimum number of clues:") +HARDER_LABEL = _("← harder") +EASIER_LABEL = _("easier →") +CANCEL_BUTTON_TEXT = _("Cancel") +OK_BUTTON_TEXT = _("OK") -CANCELLED_PROGRESS_BOX_TEXT = "Cancelling..." -STOPPING_PROGRESS_BOX_TEXT = "Stopping..." +CANCELLED_PROGRESS_BOX_TEXT = _("Cancelling...") +STOPPING_PROGRESS_BOX_TEXT = _("Stopping...") -CONFIRM_ERASE_MESSAGE_BOX_TITLE = "Erase the current game?" -CONFIRM_ERASE_MESSAGE_BOX_TEXT = "A game is in progress. Do you want to erase it?" +CONFIRM_ERASE_MESSAGE_BOX_TITLE = _("Erase current game?") +CONFIRM_ERASE_MESSAGE_BOX_TEXT = _("A game is in progress. Do you want to erase it?") -OPEN_FILE_MESSAGE_BOX_TITLE = "Open game" -FILE_TYPE_NAME = "PySudoku game" -FILE_ERROR_MESSAGE_BOX_TITLE = "File error" -CORRUPTED_FILE_MESSAGE_BOX_TEXT = "The file {} can't be read." -FILE_NOT_FOUND_MESSAGE_BOX_TEXT = "The file {} can't be found." +OPEN_FILE_MESSAGE_BOX_TITLE = _("Open game") +FILE_TYPE_NAME = _("PySudoku game") +FILE_ERROR_MESSAGE_BOX_TITLE = _("File error") +CORRUPTED_FILE_MESSAGE_BOX_TEXT = _("The file {} can't be read.") +FILE_NOT_FOUND_MESSAGE_BOX_TEXT = _("The file {} can't be found.") -SAVE_FILE_MESSAGE_BOX_TITLE = "Save game" +SAVE_FILE_MESSAGE_BOX_TITLE = _("Save game") -WIKI_URL = "https://en.wikipedia.org/wiki/Sudoku" +WIKI_URL = _("https://en.wikipedia.org/wiki/Sudoku") -ABOUT_MESSAGE_BOX_TITLE = "About PySudoku" -ABOUT_MESSAGE_BOX_TEXT = "Author: Adrien Malingrey\n" "Licence: MIT" +ABOUT_MESSAGE_BOX_TITLE = _("About PySudoku") +ABOUT_MESSAGE_BOX_TEXT = _("Author: Adrien Malingrey\n" "Licence: MIT") -CLOSE_MESSAGE_BOX_TITLE = "Save game?" -CLOSE_MESSAGE_BOX_TITLE = "A game is in progress. Would you like to save it?" +CLOSE_MESSAGE_BOX_TITLE = _("Save game?") +CLOSE_MESSAGE_BOX_TITLE = _("A game is in progress. Would you like to save it?") # 16x16, 32x32, 48x48 gif images encoded in base64 ICON16 = """ @@ -1451,7 +1462,8 @@ class App(Tk): PhotoImage(name="icon16", data=ICON16), PhotoImage(name="icon32", data=ICON32), PhotoImage(name="icon48", data=ICON48), - ) # Titlebar + ) + # Titlebar try: # Windows taskbar icon from ctypes import windll diff --git a/locale/PySudoky.mo b/locale/PySudoky.mo new file mode 100644 index 0000000..8a36b78 Binary files /dev/null and b/locale/PySudoky.mo differ diff --git a/locale/PySudoky.pot b/locale/PySudoky.pot new file mode 100644 index 0000000..9f377cb --- /dev/null +++ b/locale/PySudoky.pot @@ -0,0 +1,252 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PySudoku V0.2\n" +"POT-Creation-Date: 2018-08-02 00:12+0200\n" +"PO-Revision-Date: 2018-08-02 00:01+0200\n" +"Last-Translator: \n" +"Language-Team: Adrien Malingrey adrien.malin@protonmail.com\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.1.1\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-SearchPath-0: PySudoku.py\n" + +#: PySudoku.py:35 +msgid "PySudoku" +msgstr "" + +#: PySudoku.py:37 +msgid "Grid" +msgstr "" + +#: PySudoku.py:38 +msgid "Generate..." +msgstr "" + +#: PySudoku.py:39 +msgid "Create" +msgstr "" + +#: PySudoku.py:40 +msgid "Edit" +msgstr "" + +#: PySudoku.py:41 +msgid "Validate" +msgstr "" + +#: PySudoku.py:42 +msgid "Solve" +msgstr "" + +#: PySudoku.py:44 +msgid "Game" +msgstr "" + +#: PySudoku.py:45 +msgid "Load..." +msgstr "" + +#: PySudoku.py:46 +msgid "Save..." +msgstr "" + +#: PySudoku.py:47 +msgid "Restart..." +msgstr "" + +#: PySudoku.py:49 +msgid "View" +msgstr "" + +#: PySudoku.py:50 +msgid "Theme" +msgstr "" + +#: PySudoku.py:51 +msgid "Show tips" +msgstr "" + +#: PySudoku.py:52 +msgid "Show conflicts" +msgstr "" + +#: PySudoku.py:54 +msgid "?" +msgstr "" + +#: PySudoku.py:55 +msgid "Wikipedia" +msgstr "" + +#: PySudoku.py:56 +msgid "About..." +msgstr "" + +#: PySudoku.py:58 +msgid "Grid generation" +msgstr "" + +#: PySudoku.py:59 +msgid "Generating a new grid..." +msgstr "" + +#: PySudoku.py:60 +msgid "Deleting clues..." +msgstr "" + +#: PySudoku.py:61 +msgid "Stop" +msgstr "" + +#: PySudoku.py:63 +msgid "Grid validation" +msgstr "" + +#: PySudoku.py:64 +msgid "Checking if grid has a solution..." +msgstr "" + +#: PySudoku.py:66 +msgid "Can't solve grid" +msgstr "" + +#: PySudoku.py:68 +msgid "Some boxes have no solution. Please correct it." +msgstr "" + +#: PySudoku.py:71 +msgid "Checking if grid has other solutions..." +msgstr "" + +#: PySudoku.py:73 +msgid "Incorrect grid" +msgstr "" + +#: PySudoku.py:74 +msgid "The grid has several solutions." +msgstr "" + +#: PySudoku.py:76 +msgid "" +"Some boxes from the same row, column or region have same digit. Please " +"correct them." +msgstr "" + +#: PySudoku.py:80 +msgid "Solving grid" +msgstr "" + +#: PySudoku.py:81 +msgid "Calculating sure digits..." +msgstr "" + +#: PySudoku.py:82 +msgid "Test: {} on {}" +msgstr "" + +#: PySudoku.py:84 +msgid "There are some error. Please correct them to solve the grid." +msgstr "" + +#: PySudoku.py:87 +msgid "Cancelled" +msgstr "" + +#: PySudoku.py:89 +msgid "Congratulations!" +msgstr "" + +#: PySudoku.py:90 +msgid "The grid is solved." +msgstr "" + +#: PySudoku.py:92 +msgid "Generate a new grid" +msgstr "" + +#: PySudoku.py:93 +msgid "Please enter minimum number of clues:" +msgstr "" + +#: PySudoku.py:94 +msgid "← harder" +msgstr "" + +#: PySudoku.py:95 +msgid "easier →" +msgstr "" + +#: PySudoku.py:96 +msgid "Cancel" +msgstr "" + +#: PySudoku.py:97 +msgid "OK" +msgstr "" + +#: PySudoku.py:99 +msgid "Cancelling..." +msgstr "" + +#: PySudoku.py:100 +msgid "Stopping..." +msgstr "" + +#: PySudoku.py:102 +msgid "Erase current game?" +msgstr "" + +#: PySudoku.py:103 +msgid "A game is in progress. Do you want to erase it?" +msgstr "" + +#: PySudoku.py:105 +msgid "Open game" +msgstr "" + +#: PySudoku.py:106 +msgid "PySudoku game" +msgstr "" + +#: PySudoku.py:107 +msgid "File error" +msgstr "" + +#: PySudoku.py:108 +msgid "The file {} can't be read." +msgstr "" + +#: PySudoku.py:109 +msgid "The file {} can't be found." +msgstr "" + +#: PySudoku.py:111 +msgid "Save game" +msgstr "" + +#: PySudoku.py:113 +msgid "https://en.wikipedia.org/wiki/Sudoku" +msgstr "" + +#: PySudoku.py:115 +msgid "About PySudoku" +msgstr "" + +#: PySudoku.py:116 +msgid "" +"Author: Adrien Malingrey\n" +"Licence: MIT" +msgstr "" + +#: PySudoku.py:118 +msgid "Save game?" +msgstr "" + +#: PySudoku.py:119 +msgid "A game is in progress. Would you like to save it?" +msgstr "" diff --git a/locale/fr/LC_MESSAGES/PySudoku.mo b/locale/fr/LC_MESSAGES/PySudoku.mo new file mode 100644 index 0000000..a321fd7 Binary files /dev/null and b/locale/fr/LC_MESSAGES/PySudoku.mo differ diff --git a/locale/fr/LC_MESSAGES/PySudoku.po b/locale/fr/LC_MESSAGES/PySudoku.po new file mode 100644 index 0000000..92d2ae8 --- /dev/null +++ b/locale/fr/LC_MESSAGES/PySudoku.po @@ -0,0 +1,262 @@ +msgid "" +msgstr "" +"Project-Id-Version: PySudoku V0.2\n" +"POT-Creation-Date: 2018-08-02 00:12+0200\n" +"PO-Revision-Date: 2018-08-02 00:37+0200\n" +"Last-Translator: \n" +"Language-Team: Adrien Malingrey adrien.malin@protonmail.com\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.1.1\n" +"X-Poedit-Basepath: ../../..\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Poedit-SearchPath-0: PySudoku.py\n" + +#: PySudoku.py:35 +msgid "PySudoku" +msgstr "" + +#: PySudoku.py:37 +msgid "Grid" +msgstr "Grille" + +#: PySudoku.py:38 +msgid "Generate..." +msgstr "Générer..." + +#: PySudoku.py:39 +msgid "Create" +msgstr "Créer" + +#: PySudoku.py:40 +msgid "Edit" +msgstr "Éditer" + +#: PySudoku.py:41 +msgid "Validate" +msgstr "Valider" + +#: PySudoku.py:42 +msgid "Solve" +msgstr "Résoudre" + +#: PySudoku.py:44 +msgid "Game" +msgstr "Partie" + +#: PySudoku.py:45 +msgid "Load..." +msgstr "Charger..." + +#: PySudoku.py:46 +msgid "Save..." +msgstr "Sauvegarder..." + +#: PySudoku.py:47 +msgid "Restart..." +msgstr "Redémarrer..." + +#: PySudoku.py:49 +msgid "View" +msgstr "Affichage" + +#: PySudoku.py:50 +msgid "Theme" +msgstr "Thème" + +#: PySudoku.py:51 +msgid "Show tips" +msgstr "Afficher les info-bulles" + +#: PySudoku.py:52 +msgid "Show conflicts" +msgstr "Afficher les conflits" + +#: PySudoku.py:54 +msgid "?" +msgstr "?" + +#: PySudoku.py:55 +msgid "Wikipedia" +msgstr "Wikipédia" + +#: PySudoku.py:56 +msgid "About..." +msgstr "À propos..." + +#: PySudoku.py:58 +msgid "Grid generation" +msgstr "Génération d'une grille" + +#: PySudoku.py:59 +msgid "Generating a new grid..." +msgstr "Génération d'une nouvelle grille..." + +#: PySudoku.py:60 +msgid "Deleting clues..." +msgstr "Suppression d'indices..." + +#: PySudoku.py:61 +msgid "Stop" +msgstr "Arrêter" + +#: PySudoku.py:63 +msgid "Grid validation" +msgstr "Validation de la grille" + +#: PySudoku.py:64 +msgid "Checking if grid has a solution..." +msgstr "Vérification que la grille a une solution..." + +#: PySudoku.py:66 +msgid "Can't solve grid" +msgstr "Grille insoluble" + +#: PySudoku.py:68 +msgid "Some boxes have no solution. Please correct it." +msgstr "" +"La grille comporte des cases sans valeur possible. Corrigez-les pour pouvoir " +"valider la grille." + +#: PySudoku.py:71 +msgid "Checking if grid has other solutions..." +msgstr "Vérification qu'il n'y a pas d'autres solution..." + +#: PySudoku.py:73 +msgid "Incorrect grid" +msgstr "Grille incorrecte" + +#: PySudoku.py:74 +msgid "The grid has several solutions." +msgstr "La grille a plusieurs solutions possibles." + +#: PySudoku.py:76 +msgid "" +"Some boxes from the same row, column or region have same digit. Please " +"correct them." +msgstr "" +"La grille comporte des cases d'une même colonne, ligne ou région avec des " +"valeurs identiques. Veuillez les corriger." + +#: PySudoku.py:80 +msgid "Solving grid" +msgstr "Résolution de la grille" + +#: PySudoku.py:81 +msgid "Calculating sure digits..." +msgstr "Calcul des valeurs sûres..." + +#: PySudoku.py:82 +msgid "Test: {} on {}" +msgstr "Essai : {} en {}" + +#: PySudoku.py:84 +msgid "There are some error. Please correct them to solve the grid." +msgstr "" +"La grille comporte des erreurs. Corrigez-les pour pouvoir résoudre la grille." + +#: PySudoku.py:87 +msgid "Cancelled" +msgstr "Annulation" + +#: PySudoku.py:89 +msgid "Congratulations!" +msgstr "Bravo !" + +#: PySudoku.py:90 +msgid "The grid is solved." +msgstr "La grille est résolue." + +#: PySudoku.py:92 +msgid "Generate a new grid" +msgstr "Générer une nouvelle grille" + +#: PySudoku.py:93 +msgid "Please enter minimum number of clues:" +msgstr "Entrez le nombre minimum d'indices :" + +#: PySudoku.py:94 +msgid "← harder" +msgstr "" +"← plus\n" +"difficile" + +#: PySudoku.py:95 +msgid "easier →" +msgstr "" +"plus →\n" +"facile" + +#: PySudoku.py:96 +msgid "Cancel" +msgstr "Annuler" + +#: PySudoku.py:97 +msgid "OK" +msgstr "OK" + +#: PySudoku.py:99 +msgid "Cancelling..." +msgstr "Annulation..." + +#: PySudoku.py:100 +msgid "Stopping..." +msgstr "Arrêt..." + +#: PySudoku.py:102 +msgid "Erase current game?" +msgstr "Effacer la partie en cours ?" + +#: PySudoku.py:103 +msgid "A game is in progress. Do you want to erase it?" +msgstr "Une partie est en cours. Voulez-vous l'effacer ?" + +#: PySudoku.py:105 +msgid "Open game" +msgstr "Ouvrir une partie" + +#: PySudoku.py:106 +msgid "PySudoku game" +msgstr "Partie PySudoku" + +#: PySudoku.py:107 +msgid "File error" +msgstr "Erreur de fichier" + +#: PySudoku.py:108 +msgid "The file {} can't be read." +msgstr "Le fichier {} n'a pas pu être lu." + +#: PySudoku.py:109 +msgid "The file {} can't be found." +msgstr "Le fichier {} n'a pas été trouvé." + +#: PySudoku.py:111 +msgid "Save game" +msgstr "Enregistrer la partie" + +#: PySudoku.py:113 +msgid "https://en.wikipedia.org/wiki/Sudoku" +msgstr "https://fr.wikipedia.org/wiki/Sudoku" + +#: PySudoku.py:115 +msgid "About PySudoku" +msgstr "À propos de PySudoku" + +#: PySudoku.py:116 +msgid "" +"Author: Adrien Malingrey\n" +"Licence: MIT" +msgstr "" +"Auteur : Adrien Malingrey\n" +"Licence : MIT" + +#: PySudoku.py:118 +msgid "Save game?" +msgstr "Enregistrer la partie ?" + +#: PySudoku.py:119 +msgid "A game is in progress. Would you like to save it?" +msgstr "Une partie est en cours. Voulez-vous l'enregistrer ?"