Skip to main content
10-Marble
August 25, 2021
Solved

How to do localization for dynamic grid data's ?

  • August 25, 2021
  • 1 reply
  • 3276 views

I have data's in a grid as a string type, want to do translate those dynamic data's, but have no idea to do this, Kindly assist me to do this if any options.

Best answer by nmilleson

I would start here and maybe try out some sample calls to the API in Postman first (note you'll likely need a Google account and API key).  When you're ready to use it in a ThingWorx service, you can use the PostJSON ContentLoaderFunction to call the api with your dynamic data.

 

--Nick

1 reply

17-Peridot
August 25, 2021

@Vignesh@95 ,

 

First set up your localization tables. 

1. Add Day,FS,Gear,Shaft to your Default localization table

2. Now go to the other language localization tables and add the translated strings (the tokens will show up automatically after you add them to Default)

 

Next, in your service, you can do something like this:

let languages = Users[userName].language;

let preferredLanguage = languages.split(',')[0];

// value: STRING
let value = LocalizationTables[preferredLanguage].GetToken({
	name: valueToTranslate /* STRING */
});

 

The first line is retrieving the user's list of preferred languages from their User Profile (returned as a comma-separated list)

 

The second line is grabbing the top priority language from the list above.

 

The third line is getting that translated token from the preferred language.  Note that this assumes that the Default token name is the same as the string that you're trying to translate.  You'll have to integrate this into your infotable code but hopefully this is a good start.

 

--Nick

 

 

10-Marble
August 25, 2021

Thanks for replying, But this will work only if I know which data will be present, and also I don't know which string values will be going to present in the grid. It might be any other string values.
Is there any other way to do this because I don't know which are all the values going to be present on grid. The grid values are dynamically changing.

17-Peridot
August 25, 2021

@Vignesh@95 ,

 

If that's the case, then you may need to use a translation API like this:

https://cloud.google.com/translate

 

--Nick