Page 1 of 1
Plug in Internationalization
Posted: Mon Jan 11, 2010 10:48 pm
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?
Re: Plug in Internationalization
Posted: Mon Jan 11, 2010 10:55 pm
by Bitmonster
Do you have an example source?
Re: Plug in Internationalization
Posted: Mon Jan 11, 2010 10:58 pm
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.
Re: Plug in Internationalization
Posted: Mon Jan 11, 2010 11:16 pm
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))
^^^^
Re: Plug in Internationalization
Posted: Tue Jan 12, 2010 12:08 am
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)
Re: Plug in Internationalization
Posted: Tue Jan 12, 2010 12:14 am
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)