# Perspective - Scripting system.util.translate

**URL:** <https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716>\
**Category:** Ignition Early Access\
**Tags:** perspective, ignition80\
**Created:** [August 14, 2020, 10:49am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716 "2020-08-14T10:49:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 14, 2020, 10:49am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716/1 "2020-08-14T10:49:03Z")

</div>

I have to use the system.util.translate function for some reasons in binding and it’s very slow to proceed translation.

It takes more than 3 sec. to proceed 16 entries.

I run on a local gateway with Windows 10 pro x64, I7-10750H CPU @ 2.6GHZ, 16G RAM

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 14, 2020, 3:49pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716/2 "2020-08-14T15:49:56Z")

</div>

If you’re looping over multiple terms, then I’m not surprised. The runtime for the `system.util.translate()` is going to equate to roughly one round trip call to the Gateway, plus a query execution and response for every invocation. If you’re doing that over sixteen terms, the execution time os going to add up.

Could you post the code in question just so the use-case is clear? If you’re translating a single phrase with sixteen words it should be quicker than 3 seconds.

Are you doing this:

```auto
terms = ['Let', 'us', 'try', 'out', 'how', 'this', 'translate', 'function', 'works']
translated = []
for term in terms:
    translated.append(system.util.translate(term, 'it'))
print(translated)

```

Or something like this:

```auto
print(system.util.translate('Let us try out how this translate function works'))

```

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 14, 2020, 4:12pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716/3 "2020-08-14T16:12:37Z")

</div>

I’m building a dropdown in that case.

```auto
    from _Class import CONVERT_MM
	dv = CONVERT_MM()
	
	instances=[]
	sp = chr(160)
	#Add home position if >=0
	if not value["home"] is None and value["home"] >= 0:
		convert_val = dv.indirect(value["home"], value["unit"])
		tagVal = '{:f}'.format(convert_val)
		val = unicode("{:.3f}".format(float(tagVal)))
		lbl = system.util.translate('lbl_Home',self.session.props.locale)
		instances.append({"value":value["home"],"label": lbl + ': ' + val.rjust(10 + (6-len(val)),sp)})
	
	#add closed position if > 0
	if not value["closed"] is None and value["closed"] > 0:
		convert_val = dv.indirect(value["closed"], value["unit"])
		tagVal = '{:f}'.format(convert_val)
		val = unicode("{:.3f}".format(float(tagVal)))
		lbl = system.util.translate('lbl_Closed',self.session.props.locale)
		instances.append({"value":value["closed"],"label": lbl + ': ' + val.rjust(10 + (6-len(val)),sp)})
		
	#add mid die stop position if > 0
	if not value["mid_die"] is None and value["mid_die"] > 0:
		convert_val = dv.indirect(value["mid_die"], value["unit"])
		tagVal = '{:f}'.format(convert_val)
		val = unicode("{:.3f}".format(float(tagVal)))
		lbl = system.util.translate('lbl_MidDieStop',self.session.props.locale)
		instances.append({"value":value["mid_die"],"label": lbl + ': ' + val.rjust(10 + (6-len(val)),sp)})
	
	tag = system.tag.read(self.view.custom.moving_platten_path + "/preset/homes_nominal").value
	lbl_Home = system.util.translate('lbl_Home',self.session.props.locale)		
	for i in range(value["nb"]):
		if tag[i]<=value["closed"]:
			convert_val = dv.indirect(tag[i], value["unit"])
			tagVal = '{:f}'.format(convert_val)
			val = unicode("{:.3f}".format(float(tagVal)))
			no = unicode(str(i+1))
			instances.append({"value":tag[i],"label": lbl_Home + no.rjust(3 + (2-len(no)),sp) + ': ' + val.rjust(10 + (6-len(val)),sp)})

	return instances

```

Each translation can be a single or multiple words

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 14, 2020, 4:17pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716/4 "2020-08-14T16:17:04Z")

</div>

Is there any reason you can’t cache these translations in a script module?

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 14, 2020, 4:38pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-system-util-translate/37716/5 "2020-08-14T16:38:01Z")

</div>

For wich reason the gateway don’t translate dropdown items?
