[Tutor] Pay-at-Pump Use Case - Tkinter GUI
Jon Davies
jon_davies17 at hotmail.co.uk
Mon Mar 2 12:51:23 EST 2020
Hi Alan,
I've been having a look into internationalization / i18n , and trying to have a play to get a simple example working, however I admit I am struggling.
My basic test file (translation.py) is stored in a folder Translation, with the structure as follows:
./Translation
/translation.py
/translation.pot
/locales
/de
/LC_MESSAGES
/translation.mo
/translation.po
Within 'translation.py' is the following:
import gettext
de = gettext.translation('translation', localedir='locales', languages=['de'])
de.install()
_ = de.gettext
#_ = gettext.text
locale_path = 'locales'
def print_some_strings():
print(_('Hello world!'))
print(_('This is hopefully going to translate!'))
print(_('Hooray!'))
if __name__ == '__main__':
print_some_strings()
However, when I try to run it I get the following error:
Traceback (most recent call last):
File "C:/Users/Jon_D/__/__/__/__/__/Translation/translation.py", line 3, in <module>
de = gettext.translation('translation', localedir='locales', languages=['de'])
File "C:\Users\Jon_D\AppData\Local\Programs\Python\Python38\lib\gettext.py", line 588, in translation
raise FileNotFoundError(ENOENT,
FileNotFoundError: [Errno 2] No translation file found for domain: 'translation'
I'm confused as I'm pretty certain I've laid everything out correctly. If I can't get a simple example working god knows how I'll apply this in my app!
Thanks,
Jon
________________________________
From: Jon Davies <jon_davies17 at hotmail.co.uk>
Sent: 24 February 2020 11:05
To: Alan Gauld <alan.gauld at yahoo.co.uk>; tutor at python.org <tutor at python.org>
Subject: Re: [Tutor] Pay-at-Pump Use Case - Tkinter GUI
Thank you Alan much appreciated. I’ll have a dog and a play, will let you know how I get on!
Kind regards,
Jon
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Tutor <tutor-bounces+jon_davies17=hotmail.co.uk at python.org> on behalf of Alan Gauld via Tutor <tutor at python.org>
Sent: Sunday, February 23, 2020 6:55:08 PM
To: tutor at python.org <tutor at python.org>
Subject: Re: [Tutor] Pay-at-Pump Use Case - Tkinter GUI
On 23/02/2020 18:52, Alan Gauld via Tutor wrote:
> There is a well understood solution for this that is used
> in real world programs regardless of language
...regardless of programming language... is what I meant!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list