Removing global translations with scripting?

I know about system.util.modifyTranslation for adding or modifying global translations.
But what about removing translation (key) with scripting? Is this possible?
I didn’t find any reference for deleting single one or more keys from global translations anywhere in the documentation or on the forum…?
Oh, I’m on Ignition v7.9.14.

I found this: MutableTranslationPackage (removeKey), so it’s possible to remove translations (keys).
But I really don’t know how to use this in a script.
Can someone provide an example, please…? :pray:
@PGriffith or @KathyApplebaum maybe… this doesn’t work in v7.9.14…?

from com.inductiveautomation.ignition.gateway import IgnitionGateway
IgnitionGateway.get().getLocalizationManager().removeTerm("string")
Should do it

This is wrong; see below for an updated example.

Yes, I tried that, but the thing is, that when I'm doing:

from com.inductiveautomation.ignition.gateway import IgnitionGateway

I get an error:

IgnitionGateway, GatewayContext, and the TranslationManager are only accessible in the gateway scope. You won’t be able to run this in an event like that without sending a message to the gateway to have it execute there.

OK, I tried that with MessageHandler, still getting error:


I found out that IgnitionGateway is on V8.0.
I’m using v7.9.14(13) and I need to use SRContext.
Then I get no error but the term is also not deleted despite that log says otherwise:


When I open Translation Manager in designer, the ‘deleted’ term (key) is still there with all translations.
Even closing the designer and opening again (to refresh translations_e1_v1.dat in .ignition\cache folder… in Windows) doesn’t help.

OK, what I ended up using is this:


and is working as it should. :slightly_smiling_face:
I’m calling this from my button actionPerformed event:

1 Like

I have question not related to the topic
From the screenshot above, it seems that you have a table with all the translation terms in translation manager from which you can select one and delete. How did you populate all those terms in a table?

What I see depicted in the image is the Translation Manager. It is accessible in the designer from the "Tools" dropdown.
image

In this screenshot he shared, highlighted portion is showing he's getting the term from a table in UI.
I just want to know how to get those terms in a table, so that the operator can select the term to delete

1 Like

Ignition 8.1.36 , Windows 10

Hi ,
I'm trying to remove a translation via script, I created a messageHandler like this:

I call the message from script console with system.util.sendMessage, I have no error.

[type=Gateway,project=Diss_standard,messageHandler=translationDeleteKey,filterParams={userZones=, userRoles=Administrator, x_protectResource},isRequest=no,sendStatus=SENT]

The gateway log tells me "Removig term 'aaaa'":

But the key in the translation manager was not removed
Is there an instruction to commit the changes? Has anyone had the same problem?

Thank you

Look at @zxcslo's updated example above:

My original post was just wrong; this is the correct approach.

Hi,
the problem was SRContext was changed in IgnitionGateway

Final solution:

code:

def handleMessage(payload):
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	from com.inductiveautomation.ignition.common.i18n.translation import TranslationPackageDiff
	
	key = payload["key"]
	
	modification = TranslationPackageDiff()
	modification.removeKey(key)
	IgnitionGateway.get().getLocalizationManager().applyDiff(modification)

Thanks
Bye

2 Likes