Facebook language codes table - php
If I'm adding like-box or page-plugin so I have to choose the language in which it will be displayed.
But what if I have multilanguage-site system in PHP which remembers only country codes (en,es...). So I probably need a table like this, but with all languages:
en => en_US
es => es_ES ...
Do you know about some?
Facebook is using country codes, but this codes are a bit more specific so they are mostly called Locale ID (language and country code).
You could just grab the XML from facebook with all locale ids used by them:
<locale>
<englishName>English (UK)</englishName>
<codes>
<code>
<standard>
<name>FB</name>
<representation>en_GB</representation>
</standard>
</code>
</codes>
</locale>
You can find the whole file here (https://www.facebook.com/translations/FacebookLocales.xml)
BUT:
The Problem here is, that you cannot refer from en to en_US or en_GB. So the mapping from 2 to 4 letters won't work. You need to have a table with the language and country code like en_US.
Most modern browser send an "accept language" header, but beware It's not 100% reliable and it's just the primary language of the users browser and not really the country code.
try: var_dump( $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
to get: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
You can also try to use an API i.e. http://www.hostip.info/
An example would be:
$theFirstPart = "en";// you said you already got this
$userIP = "12.215.42.19";// from $_SERVER var
$languageCode = "en_US";// your standard
//you should use curl for this
// and it's really slow, so please cache this for at least a day or two ;)
$content = file_get_contents( "http://api.hostip.info/get_json.php?ip=$userIP" );
if( $content ) {
$json = json_decode( $content );
if( $json && isset( $json->country_code ) ) {
// before you assign the value, you should check if it's in the facebook xml
$languageCode = $theFirstPart.'_'.$json->country_code;
}
echo "<pre>";
var_dump( $languageCode );
}
Finally I created this table from all supported facebok lang-locales then I picked one using stripos() and because it few-times picked up wrong code, I re-ordered the array by putting prefered to top of the array.
Maybe it's not the best solution, but it solved my problem.
function fb_lang($lang_code){
$fb_locales = [
'es_ES', 'en_US', 'fr_FR', 'tr_TR', 'sv_SE', // prefered codes are moved to line
'af_ZA', 'sq_AL', 'ar_AR', 'hy_AM', 'ay_BO', 'az_AZ', 'eu_ES', 'be_BY', 'bn_IN', 'bs_BA', 'bg_BG', 'ca_ES', 'ck_US',
'hr_HR', 'cs_CZ', 'da_DK', 'nl_NL', 'nl_BE', 'en_PI', 'en_GB', 'en_UD', 'eo_EO', 'et_EE', 'fo_FO', 'tl_PH', 'fi_FI',
'fb_FI', 'fr_CA', 'gl_ES', 'ka_GE', 'de_DE', 'el_GR', 'gn_PY', 'gu_IN', 'he_IL', 'hi_IN', 'hu_HU', 'is_IS', 'id_ID',
'ga_IE', 'it_IT', 'ja_JP', 'jv_ID', 'kn_IN', 'kk_KZ', 'km_KH', 'tl_ST', 'ko_KR', 'ku_TR', 'la_VA', 'lv_LV', 'fb_LT', 'li_NL',
'lt_LT', 'mk_MK', 'mg_MG', 'ms_MY', 'ml_IN', 'mt_MT', 'mr_IN', 'mn_MN', 'ne_NP', 'se_NO', 'nb_NO', 'nn_NO', 'ps_AF', 'fa_IR',
'pl_PL', 'pt_BR', 'pt_PT', 'pa_IN', 'qu_PE', 'ro_RO', 'rm_CH', 'ru_RU', 'sa_IN', 'sr_RS', 'zh_CN', 'sk_SK', 'sl_SI', 'so_SO',
'es_LA', 'es_CL', 'es_CO', 'es_MX', 'es_VE', 'sw_KE', 'sy_SY', 'tg_TJ', 'ta_IN', 'tt_RU', 'te_IN', 'th_TH',
'zh_HK', 'zh_TW', 'uk_UA', 'ur_PK', 'uz_UZ', 'vi_VN', 'cy_GB', 'xh_ZA', 'yi_DE', 'zu_ZA'
];
foreach($fb_locales as $fbl){
if(stripos($fbl,$lang_code)!==false){
return $fbl;
}
}
trigger_error('Fb_lang() couldn\'t find equvalent for language code "'.$lang_code.'"');
return 'en_US';
}
Hope it will help someone else.
Related
Multilingual PHP Inline Replacement in HTML ([en]...[/en] etc.)
I am a coding beginner and have my PHP/HTML web project in German. Now I want to make it available in English in the easiest way. I don't want to add other languages in the future, so I want to try it in the easiest (and maybe not the most proper) way. I have PHP files with HTML content and the selected language available in a var, i.e.: <?php $lang = "en"; ?> <h1>Title in German</h1> So all the German words are inline HTML. My idea was to create something like: <h1>[de]Title in German[/de][en]Title in English[/en]</h1> But I have no idea how to replace it on every load in a smart way. So it is more a topic on "live replacement". Working with constants in an external language file is of course also an option, like all the other options to make a multilingual site I found on Stackoverflow. But maybe there is a "quick and dirty" possibility option like the one I mentioned? Thank you for every hint!
You could try and do this will almost only HTML and CSS. You would need to add this at the top of your page: <?php $pageLanguage = "en"; function getLanguageStyle($showLanguage) { global $pageLanguage; $display = ($showLanguage == $pageLanguage ? 'inline' : 'none'); return " span.$showLanguage { display: $display }\n"; } echo "<style>\n". getLanguageStyle('en'). getLanguageStyle('de'). "</style>\n"; ?> It sets up a style for each language, which you can then use like this: <h1><span class="de">Title in German</span><span class="en">Title in English</span></h1> The advantage here is that you don't need to mix HTML and PHP. This is not a normal way of doing this, but it will work. On very complex pages, where these styles are applied after the first render, this might not be pleasant for your visitors.
Usually translations are made that way: You have key to translation map for each language, then you request some function that takes proper map for that language and returns translation: function translate(string $lang, string $key) { /* * This usually sits in some file in dir like `/src/i18n/en.json` * And you do then `$translations = json_decode(require "/src/i18n/{$lang}.json")` */ $translations = [ 'en' => [ 'page.title' => 'Page Title', ... ], 'de' => [ 'page.title' => 'Page Title In German', ... ], ]; return $translations[$lang][$key] ?? $key; } <h1><?= translate($lang, 'page.title'); ?></h1>
Wordpress “PHP inside of PHP“ – Integrate qTranslate with Meta Box
For a Website (Wordpress) I want to display dates with the well-known plugin Meta Box and the Website should be provided in English as well as in German, with the plugin qTranslate. German and English date formats are different: German: dd.mm.y (31.12.16), English: mm/dd/y (12/31/16). So to display the right format according to the language chosen by/for the visitor, the two plugins need to work together. This is how I would display the date without any language option: <?php echo rwmb_meta( 'exhibition_meta_beginning' ); ?> This is how I would display translating text on the website outside of the post- and page-contents (like the site navigation): <?php _e("[:en]Current[:de]Aktuell[:]"); ?> My question now is, how I can join the two functions. If it helps, I would be fine with splitting the exhibition_meta_beginning in exhibition_meta_beginning_DE and exhibition_meta_beginning_EN, which would mean that I had to enter every date twice when creating a new instance/post, one in German and once in English format. I haven't found anything useful yet – yes, there are mentions of that and there is some kind of way to use Custom Fields (which is the core basis of Meta Box) with qTranslate, but nothing seems to work and my knowledge in PHP is the bare minimum. The input fields for the meta data being dates (and times) are defined in a separate PHP file like this (standard Meta Box procedure): array( 'name' => 'Beginn der Ausstellung', 'id' => $prefix . 'beginn', 'type' => 'date', 'format' => 'dd.mm.y' ), Neither did it work to implement the bilinguality into the format value right there (it thinks that it is a date's format not a language tag when [:en]... appears there), nor something like that in the part where the data is displayed (sorry for the amateurish attempt): <?php __("[:en] echo rwmb_meta( 'exhibition_meta_beginn_EN' )[:de]echo rwmb_meta( 'exhibition_meta_beginn_DE' )[:]"); ?> Thanks!
You can do it like this, $en = rwmb_meta( 'exhibition_meta_beginn_EN' ); $de = rwmb_meta( 'exhibition_meta_beginn_DE' ); echo __('[:en]'.$en.'[:de]'.$de.'[:]'); or create a function that return the value based on language function __show_based_on_lang($en, $de) { return ( qtranxf_getLanguage() == 'en') ? $en : $de ; } then to use the function you can just have it like this, echo __show_based_on_lang( rwmb_meta( 'exhibition_meta_beginn_EN' ), rwmb_meta( 'exhibition_meta_beginn_DE' ) );
Google API URL return no results
I need a PHP Google search function, so I tried many function I found in Google, but almost all have the same problem which is they take results directly from Google main URL not from the API URL, which lead after a while to an error because Google detect the visits are from a PHP server and reject any further requests. So I made my Google search function takes results from Google API URL, and that worked perfectly as you see here #API_URL until I needed to reduce the results buy adding intitle: before the searched keyword, and now the API URL return no result at all as you see here #API_URL. My question is simple, how do I get results in the Google API URL using this query intitle:maleficent+2014+site:www.anakbnet.com/video/file.php?f= so that I can take Results from it using PHP?
The data you get back from your 'Google API' call is json encoded data so you should try something like the following:- /* define a constant for ease */ define('BR','<br />'); $data='{"responseData": {"results":[{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://www.anakbnet.com/video/file.php?f\u003d1452","url":"http://www.anakbnet.com/video/file.php%3Ff%3D1452","visibleUrl":"www.anakbnet.com","cacheUrl":"http://www.google.com/search?q\u003dcache:9-JgVUvjnGYJ:www.anakbnet.com","title":"مشاهدة فيلم Alexander and the Terrible اون لاين مباشرة بدون تحميل \u003cb\u003e...\u003c/b\u003e","titleNoFormatting":"مشاهدة فيلم Alexander and the Terrible اون لاين مباشرة بدون تحميل ...","content":"29 كانون الثاني (يناير) 2015 \u003cb\u003e...\u003c/b\u003e مشاهدة فيلم \u003cb\u003eMaleficent 2014\u003c/b\u003e DVD HD مترجم اون لاين مباشرة بدون تحميل اكشن ,مغامرة \n,عائلي .. مشاهدة افلام اجنبية مترجمة اونلاين كاملة. (مشاهدة: 491,605 )."}],"cursor":{"resultCount":"1","pages":[{"start":"0","label":1}], "estimatedResultCount":"1", "currentPageIndex":0, "moreResultsUrl":"http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den-GB\u0026q\u003dmaleficent+2014+site:www.anakbnet.com/video/file.php?f%3D", "searchResultTime":"0.09"}}, "responseDetails": null, "responseStatus": 200}'; $json=json_decode( $data, true ); $res=(object)$json['responseData']['results'][0]; /* two items extracted from data - use same methodology to get other items */ echo $res->unescapedUrl; echo $res->cacheUrl; echo '<pre>'; foreach( $json as $key => $param ){ echo $key.BR; if( is_array( $param )) $param=(object)$param; print_r( $param ); } echo '</pre>'; Hopefully from that you can find what you want?!
Is there a simple way to get the language code from a country code in PHP
I'm using ISO 3166-1-alpha 2 codes to pass to an application to retrieve a localised feed e.g. /feeds/us for the USA. I have a switch statement which serves a feed based on that country_code. Is there a way to convert that two digit code to the language code e.g. en_US ? I'm wondering if there is a standard / function / library for doing this in PHP or whether I need to build my own array?
As other have pointed out, there is no built-in function as this likely due to the reality of many countries having multiple languages. So unfortunately, I can't point you to a library that does this, but I did go ahead and write a little function which does what you want. There are two caveats, one being if it isn't provided a language it will just pick the first locale in the list. To get around this, you'd have to put some logic around the function call to provide it with the appropriate language. The other is that it needs to have php5-intl installed. <?php /** /* Returns a locale from a country code that is provided. /* /* #param $country_code ISO 3166-2-alpha 2 country code /* #param $language_code ISO 639-1-alpha 2 language code /* #returns a locale, formatted like en_US, or null if not found /**/ function country_code_to_locale($country_code, $language_code = '') { // Locale list taken from: // http://stackoverflow.com/questions/3191664/ // list-of-all-locales-and-their-short-codes $locales = array('af-ZA', 'am-ET', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'arn-CL', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'as-IN', 'az-Cyrl-AZ', 'az-Latn-AZ', 'ba-RU', 'be-BY', 'bg-BG', 'bn-BD', 'bn-IN', 'bo-CN', 'br-FR', 'bs-Cyrl-BA', 'bs-Latn-BA', 'ca-ES', 'co-FR', 'cs-CZ', 'cy-GB', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LI', 'de-LU', 'dsb-DE', 'dv-MV', 'el-GR', 'en-029', 'en-AU', 'en-BZ', 'en-CA', 'en-GB', 'en-IE', 'en-IN', 'en-JM', 'en-MY', 'en-NZ', 'en-PH', 'en-SG', 'en-TT', 'en-US', 'en-ZA', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-PY', 'es-SV', 'es-US', 'es-UY', 'es-VE', 'et-EE', 'eu-ES', 'fa-IR', 'fi-FI', 'fil-PH', 'fo-FO', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR', 'fr-LU', 'fr-MC', 'fy-NL', 'ga-IE', 'gd-GB', 'gl-ES', 'gsw-FR', 'gu-IN', 'ha-Latn-NG', 'he-IL', 'hi-IN', 'hr-BA', 'hr-HR', 'hsb-DE', 'hu-HU', 'hy-AM', 'id-ID', 'ig-NG', 'ii-CN', 'is-IS', 'it-CH', 'it-IT', 'iu-Cans-CA', 'iu-Latn-CA', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'km-KH', 'kn-IN', 'kok-IN', 'ko-KR', 'ky-KG', 'lb-LU', 'lo-LA', 'lt-LT', 'lv-LV', 'mi-NZ', 'mk-MK', 'ml-IN', 'mn-MN', 'mn-Mong-CN', 'moh-CA', 'mr-IN', 'ms-BN', 'ms-MY', 'mt-MT', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'nso-ZA', 'oc-FR', 'or-IN', 'pa-IN', 'pl-PL', 'prs-AF', 'ps-AF', 'pt-BR', 'pt-PT', 'qut-GT', 'quz-BO', 'quz-EC', 'quz-PE', 'rm-CH', 'ro-RO', 'ru-RU', 'rw-RW', 'sah-RU', 'sa-IN', 'se-FI', 'se-NO', 'se-SE', 'si-LK', 'sk-SK', 'sl-SI', 'sma-NO', 'sma-SE', 'smj-NO', 'smj-SE', 'smn-FI', 'sms-FI', 'sq-AL', 'sr-Cyrl-BA', 'sr-Cyrl-CS', 'sr-Cyrl-ME', 'sr-Cyrl-RS', 'sr-Latn-BA', 'sr-Latn-CS', 'sr-Latn-ME', 'sr-Latn-RS', 'sv-FI', 'sv-SE', 'sw-KE', 'syr-SY', 'ta-IN', 'te-IN', 'tg-Cyrl-TJ', 'th-TH', 'tk-TM', 'tn-ZA', 'tr-TR', 'tt-RU', 'tzm-Latn-DZ', 'ug-CN', 'uk-UA', 'ur-PK', 'uz-Cyrl-UZ', 'uz-Latn-UZ', 'vi-VN', 'wo-SN', 'xh-ZA', 'yo-NG', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-SG', 'zh-TW', 'zu-ZA',); foreach ($locales as $locale) { $locale_region = locale_get_region($locale); $locale_language = locale_get_primary_language($locale); $locale_array = array('language' => $locale_language, 'region' => $locale_region); if (strtoupper($country_code) == $locale_region && $language_code == '') { return locale_compose($locale_array); } elseif (strtoupper($country_code) == $locale_region && strtolower($language_code) == $locale_language) { return locale_compose($locale_array); } } return null; } ?>
As noted by other answers there is no one to one mapping between countries and languages. However, if you have the PHP Intl extension installed it should be possible to use the Unicode CLDR likely subtags data to get the “default” or “likely” language for a specific country: function getLanguage(string $country): string { $subtags = \ResourceBundle::create('likelySubtags', 'ICUDATA', false); $country = \Locale::canonicalize('und_'.$country); $locale = $subtags->get($country) ?: $subtags->get('und'); return \Locale::getPrimaryLanguage($locale); } Now when you call the getLanguage() function with a country code you get the according language code back: getLanguage('US'); // "en" getLanguage('GB'); // "en" getLanguage('DE'); // "de" getLanguage('CH'); // "de" getLanguage('IN'); // "hi" getLanguage('NO'); // "nb" getLanguage('BR'); // "pt" This also works fine for three letter country codes: getLanguage('USA'); // "en" getLanguage('GBR'); // "en" getLanguage('AUT'); // "de" getLanguage('FRA'); // "fr" And even UN M49 codes: getLanguage('003'); // "en" getLanguage('013'); // "es" getLanguage('039'); // "it" getLanguage('155'); // "de"
You cannot automatically convert country code to language code because some countries use multiple languages. On the other hand, OS localization system may support multiple variants of a single language for different countries (for example, en_GB vs en_US). For example, Switzerland (CH) has both German and French commonly used (64% and 20% of the population, according to http://en.wikipedia.org/wiki/Switzerland). If you have to decide a single language for country code CH either of those languages could make sense for some people. Note that some parts of the Switzerland use only German or French as the official language (but not both, see http://en.wikipedia.org/wiki/File:Sprachen_CH_2000_EN.svg for details). If you MUST select a single language for each country, I'd suggest doing the selection by hand for every country you support. For an half-assed automatic implementation, you could scan through your available localizations and select the first one that has the matching country code after the underscore. Also note the corollary: languages cannot be represented by national flags because languages and countries do not have 1:1 relation. One to many relations can be found in both directions.
You will want to cross reference these files: http://www.ethnologue.com/codes/LanguageIndex.tab http://www.ethnologue.com/codes/CountryCodes.tab http://www.ethnologue.com/codes/LanguageCodes.tab ..or get them all in one zip here: http://www.ethnologue.com/codes/Language_Code_Data_20110104.zip There is no current set PHP function that returns this data that I'm aware of.
the answer from TheJF is pretty good, however there are a few (general) issues that I came across: his code will return br-FR if you call country_code_to_locale("FR") - now br (Breton) is not even an offical language according to Wikipedia. Although fr-FR is in the list, br-FR is the first in the array. this happens with many other countries too. many other locale lists are trying to be extremly complete and consider all possible languages it is difficult to draw the line here, good examples where you certainly want to keep multiple languages for a country are: Canada and Switzerland I went with a simple approach: I kept only 1 language for most countries, and left multiple for some countries like BE, CA, CH, ZA. I kept es-US, but I am not sure about that (Wikipedia says: Official languages: None at federal level) I also kept multiple languages for countries I was too lazy to research or that use both, Latin and Cyrillic I added shuffle($locales); which will randomize the array, such that we get random locales for countries with multiple languages. It made sense for my use case, but you might want to remove that. For my purpose, only languages that have relevant prevalence on the web are of interest. This list is by no means complete or correct, but pragmatic. So here is my locale list: $locales = array('af-ZA', 'am-ET', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-OM', 'ar-QA', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'az-Cyrl-AZ', 'az-Latn-AZ', 'be-BY', 'bg-BG', 'bn-BD', 'bs-Cyrl-BA', 'bs-Latn-BA', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'de-LI', 'de-LU', 'dv-MV', 'el-GR', 'en-AU', 'en-BZ', 'en-CA', 'en-GB', 'en-IE', 'en-JM', 'en-MY', 'en-NZ', 'en-SG', 'en-TT', 'en-US', 'en-ZA', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-EC', 'es-ES', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-PY', 'es-SV', 'es-US', 'es-UY', 'es-VE', 'et-EE', 'fa-IR', 'fi-FI', 'fil-PH', 'fo-FO', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR', 'fr-LU', 'fr-MC', 'he-IL', 'hi-IN', 'hr-BA', 'hr-HR', 'hu-HU', 'hy-AM', 'id-ID', 'ig-NG', 'is-IS', 'it-CH', 'it-IT', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'km-KH', 'ko-KR', 'ky-KG', 'lb-LU', 'lo-LA', 'lt-LT', 'lv-LV', 'mi-NZ', 'mk-MK', 'mn-MN', 'ms-BN', 'ms-MY', 'mt-MT', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'pl-PL', 'prs-AF', 'ps-AF', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'rw-RW', 'sv-SE', 'si-LK', 'sk-SK', 'sl-SI', 'sq-AL', 'sr-Cyrl-BA', 'sr-Cyrl-CS', 'sr-Cyrl-ME', 'sr-Cyrl-RS', 'sr-Latn-BA', 'sr-Latn-CS', 'sr-Latn-ME', 'sr-Latn-RS', 'sw-KE', 'tg-Cyrl-TJ', 'th-TH', 'tk-TM', 'tr-TR', 'uk-UA', 'ur-PK', 'uz-Cyrl-UZ', 'uz-Latn-UZ', 'vi-VN', 'wo-SN', 'yo-NG', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-SG', 'zh-TW'); and the code: function country_code_to_locale($country_code) { $locales = ... // randomize the array, such that we get random locales // for countries with multiple languages (CA, CH) shuffle($locales); foreach ($locales as $locale) { $locale_region = locale_get_region($locale); if (strtoupper($country_code) == $locale_region) { return $locale; } } return "en-US"; }
automatic change text into other language + google translator
In my PHP application there a new functionality I have to develop that is when user fill sign in form(html),whatever he/she put in "Name" field other two fileds i.e. "name in traditional Chinese" and "name in Chinese" should automatically filled. I want to know is it possible with google translator? if yes then please share with me code or example.
Assuming that you want the translations perfomed on the server side (PHP) you can use file_get_contents to fetch data from Google Translate API. Then you need to parse the response and get translated text. You need to get API KEY to access the Translate service. <?php $string = 'Hello World'; $source_lang = 'en'; $target_lang = 'zh-CN' header ( "Content-Type: text/html;charset=utf-8" ); $data = file_get_contents ( 'https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&q='.urlencode($string).'&source='.$source_lang.'&target='.$target_lang ); $data = json_decode ( $data ); $translated = $data->data->translations->[0]->translatedText; echo $translated; ?> Server responses are JSON objects with that structure: { "data": { "translations": [ { "translatedText": "Hallo Welt", "detectedSourceLanguage": "en" } ] } } More info about basic concept is avaliable on: http://baris.aydinoglu.info/coding/google-translate-api-in-php. Documentation of Google Translate API queries: http://code.google.com/apis/language/translate/v2/using_rest.html