July 08
For some of you that have been following the blog for a while it may not come as a surprise the fact that I have a tendency to assume things are way more clear than they are... This may yet be considered another example...
I just had an interesting IM discussion with someone that wanted to use our translation services in his web site. I told him we have plans to come up with our extensibility story, so that partners can integrate translations easier avoid the current workarounds required by the current IE8 Activities style of integration. At this point in the conversation I found out that he had no clue what I was talking about...
So let's rewind to March '08 (http://mtbotprototype.spaces.live.com/blog/cns!3F1A4578DEE8B!404.entry) - IE8 shipped with an integrated interface to our translation services. If you monitor the traffic (HttpWatch for IE) you will notice that the Preview feature is translated into a POST to an ASPX page:

Well, if that's the case, anyone posting a form request with the same elements will get a translation right? Correct, and that's exactly my point: regardless of whether we have a well documented API or now, text translation services are already available for everyone. An guess what? this is exactly the way MTBot sends the requests to the translation system...
Want something even easier? try this:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Second</title>
</head>
<body>
<!-- the iframe -->
<form method="post" action="http://www.windowslivetranslator.com/DefaultPrev.aspx?MKT=es-US&lp=en_es" target="theIFrame">
Text: <input id="SourceText" name="SourceText" type="text" />
<input id="SourceURL" name="SourceURL" type="hidden" value="" >
<input name="Submit1" type="submit" value="translate" />
</form>
<iframe frameborder="0" id="theIFrame" name="theIFrame" height="500" width="300" />
</body>
</html>
This is a very (very) basic web page that submits a text input for translation... No, seriously - that's it. The form is posted to the backend for translation AND the response is sent to the IFRAME. Use the MKT parameter to select the display language (Spanish in this case) and the lp parameter to select the language pair for the translation (in this case English to Spanish).
The markets normally match the CultureInfo culture name (in the format xx-yy); the language pairs can be retrieved from the same page you fetch - just right click on the frame body and "view source" and you will find the list of language pairs. Currently the list includes:
- ar_en = Arabic - English
- zh-chs_en = Chinese Simplified - English
- zh-cht_en = Chinese Traditional - English
- nl_en = Dutch - English
- en_ar = English - Arabic
- en_zh-chs = English - Chinese Simplified
- en_zh-cht = English - Chinese Traditional
- en_nl = English - Dutch
- en_fr = English - French
- en_de = English - German
- en_it = English - Italian
- en_ja = English - Japanese
- en_ko = English - Korean
- en_pt = English - Portuguese
- en_es = English - Spanish
- fr_en = French - English
- fr_de = French - German
- de_en = German - English
- de_fr = German - French
- it_en = Italian - English
- ja_en = Japanese - English
- ko_en = Korean - English
- pt_en = Portuguese - English
- ru_en = Russian - English
- es_en = Spanish - English
Let me know if you have problems running the sample - it should be very simple.
Enjoy!
Helvecio
English - Portuguese
Para você que têm seguido o blogue por algum tempo não pode vir como uma surpresa o fato de que eu tenho uma tendência para assumir que as coisas são mais claras do que elas são… Este pode ainda ser considerado um outro exemplo…
Eu tive uma discussão via IM muito interessante com alguém que quer usar nossos serviços de tradução em seu Web site. Eu disse-lhe que nós temos planos futuros para nossa história da extensibilidade, de modo que os partners possam integrar as traduções mais facilmente, evitando os workarounds exigidos pela interface estilo Atividades IE8 atual. Neste momento na conversa eu que ele não tinha a menor ideia do que eu estava falando…
Deixe-nos assim rebobinar a Março '08 (http://mtbotprototype.spaces.live.com/blog/cns!3F1A4578DEE8B!404.entry) - IE8 Beta foi lançado com uma interface integrada a nossos serviços de tradução. Se você monitora o tráfego (HttpWatch para o IE) você observará que a essa interface foi implementada via Http Post paraa uma página de ASPX (veja primeira figura acima).
Bem, se esse é o caso, qualquer um que mande um POST contendo um FORM com os mesmos elementos pode gerar uma tradução? Correto, e este é exatamente esse meu ponto: não obstante o fato de nós não termos uma API bem documentada, os serviços de tradução do texto já estão disponível para todos. E tem mais: esta é exatamente a maneira que MTBot emite os pedidos para o sistema da tradução…
Quer algo ainda mais fácil? tente o codigo HTML publicado acima.
Este é um exemplo muito (muito) básico de uma Web page que submete uma entrada de texto para a tradução… Não, serio - é isso mesmo. O formulário é enviado para tradução e a resposta é emitida ao IFRAME. Use o parâmetro MKT para selecionar a língua da UI (espanhol neste caso) e o parâmetro lp para selecionar o par de línguas para a tradução (neste caso de inglês para espanhol).
O MKT normalmente é o nome da cultura do CultureInfo (no formato xx-JJ); os pares de idiomas podem ser recuperados da mesma página que você busca - apenas right-click sobre o corpo do frame e "view source” e você encontrara a lista de idiomas. Atualmente a lista inclui:
- ar_en = árabe - inglês
- zh-chs_en = chinês simplificado - inglês
- zh-cht_en = tradicional chinês - inglês
- nl_en = Dutch - ingleses
- en_ar = inglês - árabe
- en_zh-chs = inglês - chineses simplificado
- en_zh-cht = inglês - tradicional chinês
- en_nl = Inglês-holandês
- en_fr = Inglês-francês
- en_de = inglês-alemão
- en_it = inglês-italiano
- en_ja = Inglês-Japonês
- en_ko = inglês - coreano
- en_pt = Inglês-Português
- en_es = inglês-espanhol
- fr_en = francês-inglês
- fr_de = francês-alemão
- de_en = alemão-inglês
- de_fr = alemão-francês
- it_en = italiano - inglês
- ja_en = Japonês-Inglês
- ko_en = coreano - inglês
- pt_en = português - inglês
- ru_en = russo-inglês
- es_en = espanhol - inglês
Deixe-me saber se você tem problemas funcionar o sample - deve ser muito simples.
Aprecie!
Helvecio
July 02
I really don't know what I'm doing wrong, but I can't get the our Live Translator button to appear in the Google Toolbar gallery... The submission goes ok, I get a confirmation page back and that's it - the button pretty much disappears and it's nowhere to be found if you search for it...
That said, I guess the last option is to publish a link to it here in the blog - it's not a perfect solution but maybe the Technorati tags can help with discoverability.
Anyway, here's the shortcut to add the button:
http://toolbar.google.com/buttons/add?url=http://translator.live.com/GButton/GTB_Translator.xml
I've tried it many times in both Firefox 2.0 and 3.0, so I expect it to work for everyone (and the content is localized, so you should see the messages in the Google Toolbar language). Please let me know if you have issues installing it.
Enjoy!
Helvecio
English - Portuguese
Eu realmente não sei o que eu estou fazendo errado, mas eu não consigo que o nosso botão para o Live Translator apareça na galeria de Google Toolbar… A submissão vai está bem, eu recebo uma página de confirmação e para por ai - o botão desaparece e não está em nenhuma parte ser encontrado se você procurar por ele…
Dessa forma, eu suponho que a última opção é publicar uma ligação aqui no blogue - não é uma solução perfeita mas talvez os Tag de Technorati podem ajudar com discoverability.
Em todo o caso, está aqui o atalho para adicionar a tecla:
http://toolbar.google.com/buttons/add?url=http://translator.live.com/GButton/GTB_Translator.xml
Eu tentei-o muitas vezes em Firefox 2.0 e 3.0, assim que eu espero-o trabalhar para todos (e o conteudo é localizado, assim que você deve ver as mensagens na língua de Google Toolbar). Deixe-me por favor saber se você tem problemas com a instalação.
Aprecie!
Helvecio