# Perspective System.util.translate Poor/Inconsistent Performance

**URL:** <https://forum.inductiveautomation.com/t/perspective-system-util-translate-poor-inconsistent-performance/45134>\
**Category:** Ignition\
**Created:** [March 31, 2021, 7:15pm UTC](https://forum.inductiveautomation.com/t/perspective-system-util-translate-poor-inconsistent-performance/45134 "2021-03-31T19:15:49Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 31, 2021, 10:06pm UTC](https://forum.inductiveautomation.com/t/perspective-system-util-translate-poor-inconsistent-performance/45134/6 "2021-03-31T22:06:33Z")

</div>

The 'round trip' back and forth is probably not as much of a problem as that post makes it out to be, but...

> [@nick.christensen1](#):
>
> Are there any workarounds for this?

Yes, absolutely. Something like this in a script library should allow you to translate many terms at once, reasonably efficiently:

```python
def translate(terms, strict=False, locale=None):
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	from com.inductiveautomation.ignition.gateway.script import GatewaySystemUtilities
	package = IgnitionGateway.get().getLocalizationManager().loadFullPackage()
	if locale is None:
		locale = GatewaySystemUtilities.LOCAL_LOCALE.get()
	fn = package.getStrict if strict else package.get
	return [fn(locale, term) for term in terms]

```

EDIT 10/13/21:  
Potentially more end-user useful, a function that returns a dictionary:

```python
def translate(terms, strict=False, locale=None):
	"""
	Translate a collection of terms in bulk, rather than all at once.

	Args:
		terms: The terms to translate.
		strict (bool): If True, a provided key without a translation will return
			None. If False, the original key will be returned.
		locale (java.util.Locale): The locale to translate values to. 
			If not provided, will attempt to use the default from the current 
			context (e.g. Perspective session or Gateway default).

	Returns:
		dict: A mapping of original keys to translated terms.
	"""
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	from com.inductiveautomation.ignition.gateway.script import GatewaySystemUtilities
	package = IgnitionGateway.get().getLocalizationManager().loadFullPackage()
	if locale is None:
		locale = GatewaySystemUtilities.LOCAL_LOCALE.get()
	fn = package.getStrict if strict else package.get
	return {term: fn(locale, term) for term in terms}

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/perspective-system-util-translate-poor-inconsistent-performance/45134)._
