Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Plug in Internationalization

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Plug in Internationalization

Post by Bartman »

I want to make a plug in ready to get translated.
I found this url=http://www.eventghost.org/wiki_old/inde ... nalization]wiki entry[[/url] but I only see the name and description of the actions and the plug in itself in the translate dialog. What am I missing?
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug in Internationalization

Post by Bitmonster »

Do you have an example source?
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Plug in Internationalization

Post by Bartman »

It is the FS20PCS plug in in the svn
http://www.eventghost.org/svn/trunk/plu ... _init__.py
It has a lot of dynamic classes and two special classes working slightly different.

P.S.
It would be great if you could upload a new beta including the plugin since the first devices will ship this week.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug in Internationalization

Post by Bitmonster »

Strings are only translatable, if they are inside a "text" class attribute of the action/plugin (with the exception of the name and description fields, that are automatically merged into such class).

So you have to do something like:

Code: Select all

    def AddNewAction(self, root, internalName, baseClass, classFuncCode, externalName, classDescription, classLabelFormat):
        class MyText:
            labelFormat = classLabelFormat
        class tmpAction(baseClass):
            text = MyText
            name = externalName
            description = classDescription
            funcCode = classFuncCode
        tmpAction.__name__ = internalName
        root.AddAction(tmpAction)
and then in your action:

Code: Select all

class SimpleAction(ActionBase):
    """Base class for all action that only take an address as input 
    """
    
    def GetLabel(self, address):
        return self.text.labelFormat.format(GetStringFromAddress(address, True))
                    ^^^^
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Plug in Internationalization

Post by Bartman »

thx works for most situations but I am not able to translate the commen texts defined in the base classes ActionBase.
If I revert using the common Text class in the file I can see the attributes in the language editor.
If I define text = Text in the base classes the text attribute gets reassigned with the dynamicly created one and I cannot cannot access the attributes from the global text.
If I directly access the Text class in the base class the original text is always shown.
I think I understand what happens, but don't know how do it right.

I am refering to the address, timerValue,.. attributes (see updated file in svn)
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Plug in Internationalization

Post by Bitmonster »

If the strings are defined in the plugin's "text" class, you have to access them through the plugin.

Code: Select all

panel.AddLine(self.plugin.text.timerValue, timerCtrl)
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Post Reply