Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Python gettext – I am afraid I do not know how to use that.

Kaworu

Active Coder
Hi!

I found this tutorial for using gettext with Python. I am in this step:

Code:
$ pygettext.py -d base -o locales/base.pot src/main.py

My locales are located in a folder like that:

Code:
C:\Users\DELL\Desktop\gettext-learning\locales

[The folder gettext-learning also contain main.py file, which is the file I wanna translate]

So I used a command like that:

Code:
C:\Users\DELL\AppData\Local\Programs\Python\Python310\Tools\i18n>pygettext.py -d base -o C:\Users\DELL\Desktop\gettext-learning\locales src/main.py



With the first use, I got:

Code:
[main 2023-05-10T11:23:27.406Z] update#setState idle

[main 2023-05-10T11:23:57.496Z] update#setState checking for updates

[main 2023-05-10T11:23:57.672Z] update#setState idle

[main 2023-05-10T11:24:07.325Z] Extension host with pid 10696 exited with code: 0, signal: unknown.

With the second:

Code:
[main 2023-05-10T11:26:03.302Z] update#setState idle

[main 2023-05-10T11:26:18.824Z] Extension host with pid 3464 exited with code: 0, signal: unknown.

The problem is, I cannot find in the locales folder the file base.pot. And I am sure my file browser shows hidden files.

Where is the base.pot file? Did it even got generated? And what exactly I am doing wrong?

Sorry if this is a trivial question, it’s my first time ever using that library and I am a total newbie...

PS. I have found some info according to which I should run the command in python, but… this is the result of such an command:

Code:
py C:\Users\DELL\AppData\Local\Programs\Python\Python310\Tools\i18n>pygettext.py -d base -o C:\Users\DELL\Desktop\gettext-learning\locales src/main.py

C:\Users\DELL\AppData\Local\Programs\Python\Python310\python.exe: can't find '__main__' module in 'C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\Python310\\Tools\\i18n'

Eh… I am totally lost :(
 
I am not familiar with all this stuff, but whenever I have doubts about the runtime location of a file, I run the Sysinternals Process Monitor while my command is executed. You can filter on Path ends with base.pot and the monitor will tell you exactly if and where this file is created, or why creation failed. This invaluable tool has saved the day for me countless times and I cannot recommend it strongly enough,
 
I had the brief look at the documentation, but it wasn't helpful. When I will find some more time, I am gonna read the whole docs, but so far no success.

Also, I think I might have screwed a little bit. Now I am trying do to things like that:

Code:
cd C:\Users\DELL\AppData\Local\Programs\Python\Python310\Tools\i18n

py pygettext.py -d base -o C:\Users\DELL\Desktop\gettext-learning\locales C:\Users\DELL\Desktop\gettext-learning\main.py

But there i still no success and I do not see the files I was hoping would get generated... eh...
 
What files were you hoping your command would generate then ? You are specifying a directory ( C:\Users\DELL\Desktop\gettext-learning\locales ) for the output file name (the -o option). This is not going to work. And why are you using both the -d and -o options to specify the output file ? That seems not right. Please run this command pygettext.py -h to see what the valid options are.

Without the -d and -o options, I believe it should be creating the file messages.pot in the current working directory (C:\Users\DELL\AppData\Local\Programs\Python\Python310\Tools\i18n). With just this option -d base it should create the file base.pot in the working directory.

BTW It would make sense to use a working directory of your own instead of a Python directory.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom