cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to do localization for dynamic grid data's ?

Vignesh@95
8-Gravel

How to do localization for dynamic grid data's ?

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5

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

 

 

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.

Vignesh@95 ,

 

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

https://cloud.google.com/translate

 

--Nick

Are there any samples or documents that represents steps to accomplish this.?

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

Top Tags