1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] localization is not working in multipage classbased application in python

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    I am using gettext to provide localization in python.I have generated the localization files ,but the localization is not working in multipage application like defining class at one file and and creating object at another file.It worked when i define and create object at same page but when i define class at one page and create object at another page,it does not work.

    working code:

    # files/y.py

    from .localization import setup_translation

    # Set the translation here
    _ = setup_translation("es")


    class Demo:
    def __init__(self, root):
    self.root = root
    self.root.title("Demo")
    self.root.geometry("500x400")
    print(_("Hello, World!"))
    print(_("Dashboard"))


    import tkinter as tk


    if __name__ == "__main__":
    root = tk.Tk()
    app = Demo(root)
    root.mainloop()


    not working code:

    import tkinter as tk
    from files.y import Demo

    if __name__ == "__main__":
    root = tk.Tk()
    app = Demo(root)
    root.mainloop()

    Continue reading...

Compartilhe esta Página