Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get translations to work. #171

Closed
dmalves opened this issue Feb 1, 2022 · 10 comments · Fixed by #175
Closed

Can't get translations to work. #171

dmalves opened this issue Feb 1, 2022 · 10 comments · Fixed by #175
Assignees
Labels
bug Something isn't working

Comments

@dmalves
Copy link

dmalves commented Feb 1, 2022

Hi,

I've got the latest ttkbootstrap from github today:

pip3 install git+https://github.com/israel-dryer/ttkbootstrap

then I cloned the repository:

git clone https://github.com/israel-dryer/ttkbootstrap

All examples work, but the translations. I tried the tests, and I could not get tableview or any dialog to be translated. I am using ubuntu linux:

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

Is there any specific command I need to choose the language? How do I know if ttkbootstrap is loading the correct the translation file? In my case it should be 'pt_br'.

EDIT: tried on python3.8.4

Thanks for your time.

@israel-dryer
Copy link
Owner

What value do you get if you run the MessageCatalog.locale() command?

@dmalves
Copy link
Author

dmalves commented Feb 1, 2022

What value do you get if you run the MessageCatalog.locale() command?

`
import ttkbootstrap as ttk
from ttkbootstrap.dialogs import Querybox, Messagebox
from ttkbootstrap.icons import Icon
from ttkbootstrap.localization import MessageCatalog
from ttkbootstrap import localization
localization.initialize_localities()

MessageCatalog.locale('pt_br')

Messagebox.yesnocancel("Messagebox.yesnocancel")

print("My locale:", MessageCatalog.locale())`
---------------- console output after pressing "yes" ---------
My locale: pt_br
---------------- screen output ----------------------
image

@dmalves
Copy link
Author

dmalves commented Feb 1, 2022

If I remove: MessageCatalog.locale('pt_br')

I still get "My locale: pt_br". Nothing changes.

@israel-dryer
Copy link
Owner

What locale is returned from the MessageCatalog.locale() method with no parameters. I'm wondering what native locale is recognized by tkinter.

@antrrax
Copy link
Contributor

antrrax commented Feb 1, 2022

Take the following test.
download the repository zip file
https://codeload.github.com/israel-dryer/ttkbootstrap/zip/refs/heads/master

extract the contents of the zip file folder

/ttkbootstrap-master/src/ttkbootstrap/

to the python modules folder. In my case python 3.8

/home/YOUR_USER_NAME/.local/lib/python3.8/site-packages/ttkbootstrap/

See if the translation has been applied


It appears to be some versioning conflict in the installation via pip


See my test:
I deleted the folder 'ttkbootstrap' and 'ttkbootstrap-1.5.1.dist-info' in the directory:

/home/YOUR_USER_NAME/.local/lib/python3.8/site-packages

and I installed it via pip:
pip3 install git+https://github.com/israel-dryer/ttkbootstrap
see the result of your code, did not apply the translation:
ingles


To fix I downloaded the zip file
https://codeload.github.com/israel-dryer/ttkbootstrap/zip/refs/heads/master

and put the contents of the folder:

/ttkbootstrap-master/src/ttkbootstrap/

in the directory:

/home/YOUR_USER_NAME/.local/lib/python3.8/site-packages/ttkbootstrap/

see the result of your code, here applied the translation:
pt


code:

import ttkbootstrap as ttk
from ttkbootstrap.dialogs import Querybox, Messagebox
from ttkbootstrap.icons import Icon
from ttkbootstrap.localization import MessageCatalog
from ttkbootstrap import localization
localization.initialize_localities()

MessageCatalog.locale('pt_br')

Messagebox.yesnocancel("Messagebox.yesnocancel")

print("My locale:", MessageCatalog.locale())

@israel-dryer
Copy link
Owner

I wonder if it's using the cached version of ttkbootstrap on the local machine?

@antrrax
Copy link
Contributor

antrrax commented Feb 1, 2022

@israel-dryer @dmalves

See the files downloaded and installed via pip (ttkbootstrap-1.5.1).
pip3 install git+https://github.com/israel-dryer/ttkbootstrap

There is no localization/msgs folder, so the translation was not applied.
ttkbootstrap_via_pip.zip


I haven't checked the other files, but it looks like the version installed via pip is not the latest from the repository,
or else it was just missing to include the folder with the translation files

@israel-dryer israel-dryer linked a pull request Feb 2, 2022 that will close this issue
@israel-dryer
Copy link
Owner

@antrrax, @dmalves, you should get the msg files now when installing via github.

@antrrax
Copy link
Contributor

antrrax commented Feb 2, 2022

I tested it here

via
pip3 install git+https://github.com/israel-dryer/ttkbootstrap

Successfully installed ttkbootstrap-1.5.1.1

It worked as expected - new version with translated text and colorchooser widget


via:
pip install ttkbootstrap
Successfully installed ttkbootstrap-1.5.1
Old version - no translation and no colorchoser

@israel-dryer israel-dryer self-assigned this Feb 2, 2022
@israel-dryer israel-dryer added the bug Something isn't working label Feb 2, 2022
@dmalves
Copy link
Author

dmalves commented Feb 2, 2022

@antrrax, @dmalves, you should get the msg files now when installing via github.
I installed the latest version using:

pip3 install git+https://github.com/israel-dryer/ttkbootstrap

Translation is working (pt_br.msg is present) on python 3.8.10 as shown bellow

image

I couldn't get it to work on python 3.9.0, but the reason is another bug:
#172

@dmalves dmalves closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants