Skip to content

Commit

Permalink
Google API key check to prevent errors when there is no key
Browse files Browse the repository at this point in the history
  • Loading branch information
klas committed Jan 17, 2012
1 parent c16d143 commit e9da1eb
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions admin/views/translate/tmpl/edit.php
Expand Up @@ -135,12 +135,12 @@ function translationWriteValue(field, value){

<script language="javascript" type="text/javascript">
function translateText(result) {
//if (!result.error) {
if (!result.error) {
translationWriteValue(this.value, result.data.translations[0].translatedText);
//}
//else {
// alert(result.error.message)
//}
}
else {
alert(result.error.message)
}
}

function googleTranslate(value) {
Expand All @@ -151,7 +151,13 @@ function googleTranslate(value) {
$code = substr($targetlang->code,0,2);
$defaultLang = substr($this->get('DefaultLanguage'),0,2);
?>


var APIKey = '<?php echo $this->googleApikey;?>';
if (!APIKey) {
alert('<?php echo JText::_('GOOGLE_TRANSLATE_API_KEY');?>');
return;
}

this.value = value;
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
Expand Down

0 comments on commit e9da1eb

Please sign in to comment.