function tmgmt_google_test_translate in TMGMT Translator Google 7
Mok service to translate request.
1 string reference to 'tmgmt_google_test_translate'
- tmgmt_google_test_menu in tests/
tmgmt_google_test.module - Implements hook_menu().
File
- tests/
tmgmt_google_test.module, line 44 - Main bootstrap file of the tmgmt_google_test module.
Code
function tmgmt_google_test_translate() {
tmgmt_google_test_key_validate();
if (empty($_GET['_q'])) {
tmgmt_google_test_trigger_response_error('global', 'required', 'Required parameter: q', 'parameter', 'q');
}
if (empty($_GET['source'])) {
tmgmt_google_test_trigger_response_error('global', 'required', 'Required parameter: source', 'parameter', 'source');
}
if (empty($_GET['target'])) {
tmgmt_google_test_trigger_response_error('global', 'required', 'Required parameter: target', 'parameter', 'target');
}
$translations = array(
'de' => 'Hallo Welt',
'fr' => 'Bonjour tout le monde',
);
$response = array(
'data' => array(
'translations' => array(
array(
'translatedText' => $translations[$_GET['target']],
),
),
),
);
drupal_json_output($response);
}