Monday, December 19, 2011

Import a Translation File into Microsoft Dynamics CRM 2011 Using .NET

This illustration shows how to import a translation file into Microsoft Dynamics CRM 2011 in code using C#  with ImportTranslationRequest.   This example will be given in C# (.NET).

JSCRIPT NOTE: At this time I am NOT providing a Jscript example on this call because of a limit in the SOAP formatter that only allows approximately 32,000 characters to a message.  Do to encoding the file in the request, the request SOAP message was hundreds of thousands of characters. It would also be difficult to reach into a user's system to get the bytes needed anyways in a practical manner from jscript.  I am not sure there is much need to do this operation in JScript they need they can comment below and I will look into it further for them.

Ok, here is what the code look like!
First in C#:

byte[] fileBytes = File.ReadAllBytes(@"C:\code\TestTranslations.zip");
ImportTranslationRequest req = new ImportTranslationRequest();
req.TranslationFile = fileBytes;
ImportTranslationResponse resp = (ImportTranslationResponse)service.Execute(req);


If you need help instantiating a service object in .NET within a plugin check out this post:
http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

I hope this helps!

1 comment:

  1. Hi, thanks a lot for your usefull Posts.
    I'm thinking of creating a Web based translation Page for CRM 2011. I would be very interested to know what do you think about it? If I create a Solution with a single Entity and Export the Translations will it be small enough to be able to import it again?
    Just for info, I'm talking about a HTML/Javascript, not the SDK way.

    ReplyDelete