Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

A Custom TAUS Data Provider for Microsoft's Multilingual App Toolkit Using Google Translate

0.00/5 (No votes)
13 Mar 2016CPOL2 min read 15K   42  
Custom TAUS Data Provider to allow increased multilingual support using Google Translate's web interface

Introduction

Microsoft has provided a convenient tool with the Multilingual App Toolkit which although currently does not scale very well to many thousands of strings due to some problems with the XLIFF tools, it has given a nice general platform to get initial multilingual translations. However, Google translate offers better support in some areas and complete support in some languages where Microsoft's providers are only partial for some of the more obscure or less common or less-English-European languages. The web interface is free and probably rate limited as Google has a professional API which would be better for very serious usage. Nonetheless, there could be some use in making a wrapper around it.

Background

Knowledge of C#, .NET and Visual Studio as well as the Multilingual App Toolkit and Resx format is beneficial.

Microsoft provides a sample TAUS Data Provider:

There is an existing Resx file translator which has a simple and primitive interface over Google Translate for arbitrary text from a source to target language on CodeProject:

The Multilingual App Toolkit v4.0 can be found at:

Using the Code

The provided file should be compiled which very simply and primitively glues together the 2 code bases referenced and the TAUSDataProvider.dll deployed as follows from the first 3 steps of the included readme.txt:

1. Place the TAUSDATAProvider.dll in "%CommonProgramFiles(x86)%\Multilingual App Toolkit"
   (and any satellite DLLS in the related sub folder. E.g.: fr-FR\TAUSDataProvider.resources.dll).

2. Update "%ALLUSERSPROFILE%\Multilingual App Toolkit\TranslationManager.xml to enable the 
   TAUS provider by adding the following XML configuration (Requires admin rights).  
   Note: Providers are used in the order listed in the configuration file.  It is recommended to 
   place this sample provider at the top to ensure it is given priority during translation and 
   suggestions.

   ...
    <provider>
      <id>3AB3DC49-4A77-4371-AFBB-21876E25A40B</id>
      <name>TAUSDataProvider</name>
      <configfile>TAUSDataProvider\TAUSDataSettings.xml</configfile>
      <assemblypath>TAUSDataProvider.dll</assemblypath>
    </provider>
   ...
   
3. Copy the TAUSDataSetting.xml file to the 
   "%ALLUSERSPROFILE%\Multilingual App Toolkit\TAUSDataProvider" 
   folder.  This is the TAUS DATA Provider configuration setting used 
   to access the Windows Credential Manager store.
   
   Take special note as you will need to also copy a DLL before building 
   if a new Multilingual App Toolkit is released and you choose to use it: 
   The provider needs to be compiled against the same build 
   as the Microsoft.Multilingual.Translation.dll installed on your system.  
   If you try to translate a resource, the load error will be displayed
   in the Editor Message tab or in  Visual Studio's output panel. 
   The message should provide the details of the error.

You must make sure any source/target languages which use country or region codes are added manually to the GetLanguages list in TAUSDataAccess.cs and any supported by Google which are not listed are added in Language.cs to the TranslatableCollection as more have been added since the Resx Translator tool was created.

Points of Interest

Better HTML parsing could dynamically fetch the language list from Google translate. As well, the suggestion list is also provided, one inline with the translation, and one listed below with varying parts of speech which would make this a more complete translation (HTMLAgilityPack might make a nice parser for this).

This is also a demonstration to show that a TAUS provider can in theory be emulated with a service which does not match its protocal and requires no credentials.

Hammering Google's web server will probably cause problems as they have a paid API service which would be preferable to use here for doing very serious resx translation projects or 403 type errors are certainly possible. The code could be modified to account for these and sleep for some amount of time as well...

History

  • Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)