Index: gp-includes/google.php
===================================================================
--- gp-includes/google.php	(revision 546)
+++ gp-includes/google.php	(working copy)
@@ -4,12 +4,12 @@
 	if ( !$locale->google_code ) {
 		return new WP_Error( 'google_translate', sprintf( "The locale %s isn't supported by Google Translate.", $locale->slug ) );
 	}
-	$url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=' . urlencode( 'en|'.$locale->google_code );
+	$url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&key=' . gp_const_get( 'GP_GOOGLE_KEY' ) . '&langpair=' . urlencode( 'en|'.$locale->google_code );
 	foreach ( $strings as $string ) {
 		$url .= '&q=' . urlencode( $string );
 	}
-	if ( count( $strings ) == 1 ) $url .= '&q=';
-	$response = wp_remote_get( $url );
+	if ( !$strings ) return array();
+	$response = wp_remote_get( $url, array( 'headers' => array( 'Referer' => gp_url_current() ) ) );
 	if ( is_wp_error( $response ) ) {
 		return $response;
 	}
@@ -39,5 +39,6 @@
 function google_translate_fix( $string ) {
 	$string = preg_replace_callback( '/% (s|d)/i', lambda( '$m', '"%".strtolower($m[1])' ), $string );
 	$string = preg_replace_callback( '/% (\d+) \$ (s|d)/i', lambda( '$m', '"%".$m[1]."\\$".strtolower($m[2])' ), $string );
+	$string = str_replace( array( '&#39;', '&quot;', '&amp;' ), array( '\'', '"', '&' ), $string );
 	return $string;
 }
\ No newline at end of file
Index: gp-includes/microsoft.php
===================================================================
--- gp-includes/microsoft.php	(revision 0)
+++ gp-includes/microsoft.php	(revision 0)
@@ -0,0 +1,27 @@
+<?php
+
+function bing_translate_batch( $locale, $strings ) {
+	if ( !$locale->bing_code ) {
+		return new WP_Error( 'bing_translate', sprintf( "The locale %s isn't supported by Bing Translate.", $locale->slug ) );
+	}
+	if ( !$strings ) return array();
+
+	$response = wp_remote_post( 'http://api.microsofttranslator.com/v2/Http.svc/TranslateArray', array( 'body' => '<TranslateArrayRequest><AppId>' . gp_const_get( 'GP_BING_KEY' ) . '</AppId><Options><Category xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2">general</Category><ContentType xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2">text/plain</ContentType><State xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2">GlotPress</State><Uri xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2">all</Uri><User xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2">all</User></Options><Texts><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">' . implode( '</string><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">', array_map( 'esc_html', $strings ) ) . '</string></Texts><From>en</From><To>bg</To></TranslateArrayRequest>', 'headers' => array( 'Content-Type' => 'text/xml' ) ) );
+	if ( is_wp_error( $response ) )
+		return $response;
+	$response = wp_remote_retrieve_body( $response );
+	$response = @new SimpleXMLElement( $response );
+
+	$translations = array();
+	foreach ( $response->TranslateArrayResponse as $translated ) {
+		$translations[] = bing_translate_fix( utf8_encode( $translated->TranslatedText ) );
+	}
+	return $translations;
+}
+
+function bing_translate_fix( $string ) {
+	$string = preg_replace_callback( '/% (s|d)/i', lambda( '$m', '"%".strtolower($m[1])' ), $string );
+	$string = preg_replace_callback( '/% (\d+) \$ (s|d)/i', lambda( '$m', '"%".$m[1]."\\$".strtolower($m[2])' ), $string );
+	$string = str_replace( array( '&#39;', '&quot;', '&amp;' ), array( '\'', '"', '&' ), $string );
+	return $string;
+}
\ No newline at end of file

Property changes on: gp-includes\microsoft.php
___________________________________________________________________
Added: svn:eol-style
   + native

Index: locales/locales.php
===================================================================
--- locales/locales.php	(revision 546)
+++ locales/locales.php	(working copy)
@@ -110,6 +110,7 @@
 		$ar->country_code = '';
 		$ar->wp_locale = 'ar';
 		$ar->slug = 'ar';
+		$ar->bing_code = 'ar';
 		$ar->google_code = 'ar';
 		$ar->nplurals = 6;
 		$ar->plural_expression = 'n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5';
@@ -188,6 +189,7 @@
 		$bg->country_code = 'bg';
 		$bg->wp_locale = 'bg_BG';
 		$bg->slug = 'bg';
+		$bg->bing_code = 'bg';
 		$bg->google_code = 'bg';
 
 		$bh = new GP_Locale();
@@ -311,6 +313,7 @@
 		$cs->country_code = 'cz';
 		$cs->wp_locale = 'cs_CZ';
 		$cs->slug = 'cs';
+		$cs->bing_code = 'cs';
 		$cs->google_code = 'cs';
 		$cs->nplurals = 3;
 		$cs->plural_expression = '(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2';
@@ -361,6 +364,7 @@
 		$da->country_code = 'dk';
 		$da->wp_locale = 'da_DK';
 		$da->slug = 'da';
+		$da->bing_code = 'da';
 		$da->google_code = 'da';
 		
 		$de = new GP_Locale();
@@ -425,6 +429,7 @@
 		$en->country_code = 'us';
 		$en->wp_locale = 'en_US';
 		$en->slug = 'en';
+		$en->bing_code = 'en';
 		$en->google_code = 'en';
 
 		$eo = new GP_Locale();
@@ -484,6 +489,7 @@
 		$es->country_code = 'es';
 		$es->wp_locale = 'es_ES';
 		$es->slug = 'es';
+		$es->bing_code = 'es';
 		$es->google_code = 'es';
 		
 		$et = new GP_Locale();
@@ -494,6 +500,7 @@
 		$et->country_code = 'ee';
 		$et->wp_locale = 'et';
 		$et->slug = 'et';
+		$et->bing_code = 'et';
 		$et->google_code = 'et';
 
 		$eu = new GP_Locale();
@@ -638,6 +645,7 @@
 		$he->country_code = 'il';
 		$he->wp_locale = 'he_IL';
 		$he->slug = 'he';
+		$he->bing_code = 'he';
 		$he->google_code = 'iw';
 		$he->rtl = true;
 
@@ -671,6 +679,7 @@
 		$hu->country_code = 'hu';
 		$hu->wp_locale = 'hu_HU';
 		$hu->slug = 'hu';
+		$hu->bing_code = 'hu';
 		$hu->google_code = 'hu';
 
 		$hy = new GP_Locale();
@@ -731,6 +740,7 @@
 		$it->country_code = 'it';
 		$it->wp_locale = 'it_IT';
 		$it->slug = 'it';
+		$it->bing_code = 'it';
 		$it->google_code = 'it';
 
 		$ja = new GP_Locale();
@@ -740,6 +750,7 @@
 		$ja->country_code = 'jp';
 		$ja->wp_locale = 'ja';
 		$ja->slug = 'ja';
+		$ja->bing_code = 'ja';
 		$ja->google_code = 'ja';
 		$ja->nplurals = 1;
 		$ja->plural_expression = '0';
@@ -803,6 +814,7 @@
 		$ko->country_code = 'kr';
 		$ko->wp_locale = 'ko_KR';
 		$ko->slug = 'ko';
+		$ko->bing_code = 'ko';
 		$ko->google_code = 'ko';
 		$ko->nplurals = 1;
 		$ko->plural_expression = '0';
@@ -873,6 +885,7 @@
 		$lv->country_code = 'lv';
 		$lv->wp_locale = 'lv';
 		$lv->slug = 'lv';
+		$lv->bing_code = 'lv';
 		$lv->google_code = 'lv';
 		$lv->nplurals = 3;
 		$lv->plural_expression = '(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2)';
@@ -974,6 +987,7 @@
 		$nl->country_code = 'nl';
 		$nl->wp_locale = 'nl';
 		$nl->slug = 'nl';
+		$nl->bing_code = 'nl';
 		$nl->google_code = 'nl';
 
 		$nn = new GP_Locale();
@@ -992,6 +1006,7 @@
 		$no->lang_code_iso_639_2 = 'nor';
 		$no->country_code = 'no';
 		$no->slug = 'no';
+		$no->bing_code = 'no';
 		$no->google_code = 'no';
 
 		$oc = new GP_Locale();
@@ -1018,6 +1033,7 @@
 		$pl->country_code = 'pl';
 		$pl->wp_locale = 'pl_PL';
 		$pl->slug = 'pl';
+		$pl->bing_code = 'pl';
 		$pl->google_code = 'pl';
 		$pl->nplurals = 3;
 		$pl->plural_expression = '(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)';
@@ -1042,6 +1058,7 @@
 		$pt->country_code = 'pt';
 		$pt->wp_locale = 'pt_PT';
 		$pt->slug = 'pt';
+		$pt->bing_code = 'pt';
 		$pt->google_code = 'pt-PT';
 
 		$ro = new GP_Locale();
@@ -1052,6 +1069,7 @@
 		$ro->country_code = 'ro';
 		$ro->wp_locale = 'ro_RO';
 		$ro->slug = 'ro';
+		$ro->bing_code = 'ro';
 		$ro->google_code = 'ro';
 		$ro->nplurals = 3;
 		$ro->plural_expression = '(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);';
@@ -1076,6 +1094,7 @@
 		$ru->country_code = 'ru';
 		$ru->wp_locale = 'ru_RU';
 		$ru->slug = 'ru';
+		$ru->bing_code = 'ru';
 		$ru->google_code = 'ru';
 		$ru->nplurals = 3;
 		$ru->plural_expression = '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)';
@@ -1117,6 +1136,7 @@
 		$sk->country_code = 'sk';
 		$sk->slug = 'sk';
 		$sk->wp_locale = 'sk_SK';
+		$sk->bing_code = 'sk';
 		$sk->google_code = 'sk';
 		$sk->nplurals = 3;
 		$sk->plural_expression = '(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2';
@@ -1129,6 +1149,7 @@
 		$sl->country_code = 'si';
 		$sl->wp_locale = 'sl_SI';
 		$sl->slug = 'sl';
+		$sl->bing_code = 'sl';
 		$sl->google_code = 'sl';
 		$sl->nplurals = 4;
 		$sl->plural_expression = '(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)';
@@ -1174,6 +1195,7 @@
 		$sv->country_code = 'se';
 		$sv->wp_locale = 'sv_SE';
 		$sv->slug = 'sv';
+		$sv->bing_code = 'sv';
 		$sv->google_code = 'sv';
 
 		$sw = new GP_Locale();
@@ -1214,6 +1236,7 @@
 		$th->country_code = '';
 		$th->wp_locale = 'th';
 		$th->slug = 'th';
+		$th->bing_code = 'th';
 		$th->google_code = 'th';
 		$th->nplurals = 1;
 		$th->plural_expression = '0';
@@ -1245,6 +1268,7 @@
 		$tr->country_code = 'tr';
 		$tr->wp_locale = 'tr_TR';
 		$tr->slug = 'tr';
+		$tr->bing_code = 'tr';
 		$tr->google_code = 'tr';
 		$tr->nplurals = 1;
 		$tr->plural_expression = '0';
@@ -1349,6 +1373,7 @@
 		$zh_cn->country_code = 'cn';
 		$zh_cn->wp_locale = 'zh_CN';
 		$zh_cn->slug = 'zh-cn';
+		$zh_cn->bing_code = 'zh-CHS';
 		$zh_cn->google_code = 'zh-CN';
 		$zh_cn->nplurals = 1;
 		$zh_cn->plural_expression = '0';
@@ -1382,6 +1407,7 @@
 		$zh_tw->country_code = 'tw';
 		$zh_tw->slug = 'zh-tw';
 		$zh_tw->wp_locale= 'zh_TW';
+		$zh_tw->bing_code = 'zh-CHT';
 		$zh_tw->google_code = 'zh-TW';
 		$zh_tw->nplurals = 1;
 		$zh_tw->plural_expression = '0';

