Translation Manager Insert Bulk record

Hi,

i am using message handler to insert data in to Translation manager in different gateways

def handleMessage(payload):

	English_lang = payload['English']
	Translate_lang = payload['Translated_lang']
	Lang_code = payload['Language_code']
	
	system.util.modifyTranslation(English_lang,Translate_lang,Lang_code)

But i want to do bulk insert using excel file.
How to pass the excel file in payload and insert the record in translation manager for different gateways at same time?

Don't, you'll run into headaches. Instead, parse the file in whatever event where you are accessing it, and build some type of data structure to send as the payload.

For instance I would be tempted to build a dictionary where the English is the key.

payload = {'Translations':{'English 1':{'Translated_lang':'translated lang','Language_code':'language code'},'English 2':{'Translaged_lang':'translaged lang','Language_code':'language code'}}}

then loop through that in your message handler:

def handleMessage(payload):

    translations = payload['Translations']

    for english,vals in translations.iteritems():
        system.util.modifyTranslation(english,vals['Translated_lang'],vals['Language_code'])

Note: Depending on how many of these you need to do, you may need to consider breaking the file into manageable chunks.

1 Like

Its very confusing for me how your dictionary works

for exmple

english   french      language code
Helo      HĂ©lo           fr
read      lis                fr
write     Ă©crivez         fr

Can you please take this as example and build your dictionary for this one

It will help full for me to understand

I would use a list of dictionaries.

payload = {'data' : [{'keyIn':'Hello', 'Translated_lang':'HĂ©lo',    'Language_code':'fr'},
					 {'keyIn':'read',  'Translated_lang':'lis',     'Language_code':'fr'},
					 {'keyIn':'write', 'Translated_lang':'Ă©crivez', 'Language_code':'fr'},
					]
		  }
		  
for row in payload['data']:
	system.util.modifyTranslation(row['keyIn'], row['Translated_lang'], row['Language_code'])

I know we usually say English for the key, but the key can really be anything.

1 Like

One question… If front end user wants to add records to translation manager.

Is there any alternative way to do it?

That scripting function also works in the client if users have the Translation Management permission.

3 Likes