--- a/PLCControler.py Fri Jul 24 12:49:57 2009 +0200
+++ b/PLCControler.py Fri Jul 24 17:12:59 2009 +0200
@@ -77,6 +77,16 @@
ScriptDirectory = os.path.split(os.path.realpath(__file__))[0]
+def GetUneditableNames():
+ _ = lambda x:x
+ return [_("User-defined POUs"), _("Functions"), _("Function Blocks"),
+ _("Programs"), _("Data Types"), _("Transitions"), _("Actions"),
+ _("Configurations"), _("Resources"), _("Properties")]
+UNEDITABLE_NAMES = GetUneditableNames()
+[USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS,
+ DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS,
+ RESOURCES, PROPERTIES] = UNEDITABLE_NAMES
+
#-------------------------------------------------------------------------------
# Undo Buffer for PLCOpenEditor
#-------------------------------------------------------------------------------
@@ -280,7 +290,7 @@
self.FilePath = filepath
if filepath == "":
self.LastNewIndex += 1
- self.FileName = "Unnamed%d"%self.LastNewIndex
+ self.FileName = _("Unnamed%d")%self.LastNewIndex
else:
self.FileName = os.path.splitext(os.path.basename(filepath))[0]
@@ -309,13 +319,13 @@
project = self.GetProject(debug)
if project is not None:
infos = {"name": project.getname(), "type": ITEM_PROJECT}
- datatypes = {"name": "Data Types", "type": ITEM_DATATYPES, "values":[]}
+ datatypes = {"name": DATA_TYPES, "type": ITEM_DATATYPES, "values":[]}
for datatype in project.getdataTypes():
datatypes["values"].append({"name": datatype.getname(), "type": ITEM_DATATYPE,
"tagname": self.ComputeDataTypeName(datatype.getname()), "values": []})
- pou_types = {"function": {"name": "Functions", "type": ITEM_FUNCTION, "values":[]},
- "functionBlock": {"name": "Function Blocks", "type": ITEM_FUNCTIONBLOCK, "values":[]},
- "program": {"name": "Programs", "type": ITEM_PROGRAM, "values":[]}}
+ pou_types = {"function": {"name": FUNCTIONS, "type": ITEM_FUNCTION, "values":[]},
+ "functionBlock": {"name": FUNCTION_BLOCKS, "type": ITEM_FUNCTIONBLOCK, "values":[]},
+ "program": {"name": PROGRAMS, "type": ITEM_PROGRAM, "values":[]}}
for pou in project.getpous():
pou_type = pou.getpouType()
pou_infos = {"name": pou.getname(), "type": ITEM_POU,
@@ -327,23 +337,23 @@
transitions.append({"name": transition.getname(), "type": ITEM_TRANSITION,
"tagname": self.ComputePouTransitionName(pou.getname(), transition.getname()),
"values": []})
- pou_values.append({"name": "Transitions", "type": ITEM_TRANSITIONS, "values": transitions})
+ pou_values.append({"name": TRANSITIONS, "type": ITEM_TRANSITIONS, "values": transitions})
actions = []
for action in pou.getactionList():
actions.append({"name": action.getname(), "type": ITEM_ACTION,
"tagname": self.ComputePouActionName(pou.getname(), action.getname()),
"values": []})
- pou_values.append({"name": "Actions", "type": ITEM_ACTIONS, "values": actions})
+ pou_values.append({"name": ACTIONS, "type": ITEM_ACTIONS, "values": actions})
if pou_type in pou_types:
pou_infos["values"] = pou_values
pou_types[pou_type]["values"].append(pou_infos)
- configurations = {"name": "Configurations", "type": ITEM_CONFIGURATIONS, "values": []}
+ configurations = {"name": CONFIGURATIONS, "type": ITEM_CONFIGURATIONS, "values": []}
for config in project.getconfigurations():
config_name = config.getname()
config_infos = {"name": config_name, "type": ITEM_CONFIGURATION,
"tagname": self.ComputeConfigurationName(config.getname()),
"values": []}
- resources = {"name": "Resources", "type": ITEM_RESOURCES, "values": []}
+ resources = {"name": RESOURCES, "type": ITEM_RESOURCES, "values": []}
for resource in config.getresource():
resource_name = resource.getname()
resource_infos = {"name": resource_name, "type": ITEM_RESOURCE,
@@ -352,7 +362,7 @@
resources["values"].append(resource_infos)
config_infos["values"] = [resources]
configurations["values"].append(config_infos)
- infos["values"] = [{"name": "Properties", "type": ITEM_PROPERTIES, "values": []},
+ infos["values"] = [{"name": PROPERTIES, "type": ITEM_PROPERTIES, "values": []},
datatypes, pou_types["function"], pou_types["functionBlock"],
pou_types["program"], configurations]
return infos
@@ -1165,7 +1175,7 @@
blocktypes = [category for category in BlockTypes + self.PluginTypes]
project = self.GetProject(debug)
if project is not None:
- blocktypes.append({"name" : "User-defined POUs", "list": project.GetCustomBlockTypes(name, type == "function" or words[0] == "T")})
+ blocktypes.append({"name" : USER_DEFINED_POUS, "list": project.GetCustomBlockTypes(name, type == "function" or words[0] == "T")})
return blocktypes
# Return Function Block types checking for recursion
@@ -2522,7 +2532,7 @@
self.Buffering = False
self.CurrentElementEditing = None
return None
- return "No PLC project found"
+ return _("No PLC project found")
def SaveXMLFile(self, filepath = None):
if not filepath and self.FilePath == "":