From cd5a0df28384419260d5b1345dde3846e220ea97 Mon Sep 17 00:00:00 2001 From: spiderr Date: Sat, 30 Apr 2011 02:04:35 -0400 Subject: add auto button to get all empty translations, however javascript speed choking issue --- templates/translate_strings.tpl | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'templates/translate_strings.tpl') diff --git a/templates/translate_strings.tpl b/templates/translate_strings.tpl index 0d43dfe..7f19543 100644 --- a/templates/translate_strings.tpl +++ b/templates/translate_strings.tpl @@ -5,15 +5,31 @@ {literal} var ajax = new BitBase.SimpleAjax(); function autoTranslate( pElementId ) { -console.log( pElementId ); ajax.connect( "{/literal}{$smarty.const.LANGUAGES_PKG_URL}ajax_translate.php{literal}" , "lang={/literal}{$editLang}{literal}&source_hash=" + escape( pElementId ) - , function (r) { - document.getElementById( 'h_'+pElementId ).value = r.responseText; - } + , updateTranslation , "GET" ); } + +function updateTranslation( pResponse ) { + rObj = eval('(' + pResponse.responseText + ')'); + document.getElementById( rObj.source_hash ).value = rObj.translation; +} + +function autoTranslateEmpty() { + var elem = document.getElementById('translateform').elements; + for(var i = 0; i < elem.length; i++) { + if( elem[i].type == 'text' || elem[i].type == 'textarea' ) { + if( !elem[i].value && elem[i].id ) { +console.log( elem[i].type + " -> " + elem[i].id ); + autoTranslate( elem[i].id ); +return; + } + } + } +} + {/literal} /* ]]> */ @@ -23,7 +39,7 @@ console.log( pElementId );
- {form} + {form id="translateform"}
{formlabel label="Select the language to edit" for="select_language"} {forminput} @@ -38,7 +54,7 @@ console.log( pElementId ); {/forminput}
- {alphabar iall=1 lang=$smarty.request.lang translate=1 un_trans=$unTrans all_trans=$allTrans} + {alphabar iall=1 choose_lang=$smarty.request.lang translate=1 un_trans=$unTrans all_trans=$allTrans} @@ -49,7 +65,7 @@ console.log( pElementId ); {if $allTrans || (!$gBitSystem->isFeatureActive( 'i18n_track_translation_usage' ) || $tran.version)}
- + {if $gBitSystem->getConfig('google_api_key')}
{biticon iname="google-favicon" ipackage="languages" iexplain="Auto-Translate"} Auto
{/if} @@ -57,9 +73,9 @@ console.log( pElementId ); {forminput} {$tran.source|escape|nl2br}
{if $tran.textarea} - + {else} - + {/if} {/forminput}
@@ -69,6 +85,9 @@ console.log( pElementId );
  + {if $gBitSystem->getConfig('google_api_key')} +
Auto Translate Empty Strings
+ {/if}
{alphabar iall=1 lang=$editLang translate=1 un_trans=$unTrans all_trans=$allTrans} -- cgit v1.3