[-] BO : fix #PSCFV-2366 : check if an sentence use an specific syntax

This commit is contained in:
lLefevre
2012-05-21 17:31:48 +00:00
parent 21ed1ef008
commit acb3b2e7d2
7 changed files with 240 additions and 83 deletions
@@ -28,15 +28,6 @@
{block name="override_tpl"}
<div class="hint" style="display:block;">
{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations|array_sum}<br />
</p>
{if $post_limit_exceeded}
<div class="warn">
{if $limit_warning['error_type'] == 'suhosin'}
@@ -53,6 +44,43 @@
{l s='%s at least or edit the translation file manually.' sprintf=$limit_warning['needed_limit']}
</div>
{else}
<div class="hint" style="display:block;">
{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations|array_sum}<br />
</p>
<script type="text/javascript">
$(document).ready(function(){
$('a.useSpecialSyntax').click(function(){
var syntax = $(this).find('img').attr('alt');
$('#BoxUseSpecialSyntax .syntax span').html(syntax);
$('#BoxUseSpecialSyntax').toggle(1000);
});
$('#BoxUseSpecialSyntax').click(function(){
$('#BoxUseSpecialSyntax').toggle(1000);
});
});
</script>
<div id="BoxUseSpecialSyntax">
<div class="warn">
<p class="syntax">
{l s='This expression uses this special syntax:'} <span>%d</span><br />
{l s='You must use this syntax in your tanslations. Here are several examples of use:'}
</p>
<ul>
<li><em>There are <strong>%d</strong> products</em> ("<strong>%d</strong>" {l s='will be replaced by a number'}).</li>
<li><em>List of pages in <strong>%s</strong>:</em> ("<strong>%s</strong>" {l s='will be replaced by a string'}).</li>
<li><em>Feature: <strong>%1$s</strong> (<strong>%2$d</strong> values)</em> ("<strong>n$</strong>" {l s='is used for the order of the arguments'}).</li>
</ul>
</div>
</div>
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
{*{$auto_translate}$*}
<input type="hidden" name="lang" value="{$lang}" />
@@ -62,9 +90,16 @@
<br /><br />
<table cellpadding="0" cellspacing="0" class="table">
{foreach $errorsArray as $key => $value}
<tr {if empty($value)}style="background-color:#FBB"{else}{cycle values='class="alt_row",'}{/if}>
<tr {if empty($value.trad)}style="background-color:#FBB"{else}{cycle values='class="alt_row",'}{/if}>
<td>{$key|stripslashes}</td>
<td style="width: 430px">= <input type="text" name="{$key|md5}" value="{$value|regex_replace:'#"#':'&quot;'|stripslashes}" style="width: 380px"></td>
<td style="width: 430px">=
<input type="text" name="{$key|md5}" value="{$value.trad|regex_replace:'#"#':'&quot;'|stripslashes}" style="width: 380px">
{if isset($value.use_sprintf) && $value.use_sprintf}
<a class="useSpecialSyntax" title="{l s='This expression uses a special syntax:'} {$value.use_sprintf}" style="cursor:pointer">
<img src="{$smarty.const._PS_IMG_}admin/error.png" alt="{$value.use_sprintf}" />
</a>
{/if}
</td>
</tr>
{/foreach}
</table>
@@ -28,18 +28,6 @@
{block name="override_tpl"}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
<li>{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}</li>
</ul>
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations|array_sum}<br />
</p>
{if $post_limit_exceeded}
<div class="warn">
{if $limit_warning['error_type'] == 'suhosin'}
@@ -56,12 +44,53 @@
{l s='%s at least or edit the translation file manually.' sprintf=$limit_warning['needed_limit']}
</div>
{else}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
<li>{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}</li>
</ul>
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations|array_sum}<br />
</p>
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
{$toggle_button}
<input type="hidden" name="lang" value="{$lang}" />
<input type="hidden" name="type" value="{$type}" />
<input type="hidden" name="theme" value="{$theme}" />
<input type="submit" id="{$table}_form_submit_btn" name="submitTranslations{$type|ucfirst}" value="{l s='Update translations'}" class="button" />
<script type="text/javascript">
$(document).ready(function(){
$('a.useSpecialSyntax').click(function(){
var syntax = $(this).find('img').attr('alt');
$('#BoxUseSpecialSyntax .syntax span').html(syntax);
$('#BoxUseSpecialSyntax').toggle(1000);
});
$('#BoxUseSpecialSyntax').click(function(){
$('#BoxUseSpecialSyntax').toggle(1000);
});
});
</script>
<div id="BoxUseSpecialSyntax">
<div class="warn">
<p class="syntax">
{l s='This expression uses this special syntax:'} <span>%d</span><br />
{l s='You must use this syntax in your tanslations. Here are several examples of use:'}
</p>
<ul>
<li><em>There are <strong>%d</strong> products</em> ("<strong>%d</strong>" {l s='will be replaced by a number'}).</li>
<li><em>List of pages in <strong>%s</strong>:</em> ("<strong>%s</strong>" {l s='will be replaced by a string'}).</li>
<li><em>Feature: <strong>%1$s</strong> (<strong>%2$d</strong> values)</em> ("<strong>n$</strong>" {l s='is used for the order of the arguments'}).</li>
</ul>
</div>
</div>
<br /><br />
{foreach $tabsArray as $k => $newLang}
{if !empty($newLang)}
@@ -78,13 +107,18 @@
<td style="width:40%">{$key|stripslashes}</td>
<td>= {*todo : md5 is already calculated in AdminTranslationsController*}
{if $key|strlen < $textarea_sized}
<input type="text" style="width: 450px{if empty($value)};background:#FBB{/if}"
<input type="text" style="width: 450px{if empty($value.trad)};background:#FBB{/if}"
name="{if in_array($type, array('front', 'fields'))}{$k}_{$key|md5}{else}{$k}{$key|md5}{/if}"
value="{$value|regex_replace:'/"/':'&quot;'|stripslashes}" />
value="{$value.trad|regex_replace:'/"/':'&quot;'|stripslashes}" />
{else}
<textarea rows="{($key|strlen / $textarea_sized)|intval}" style="width: 450px{if empty($value)};background:#FBB{/if}"
<textarea rows="{($key|strlen / $textarea_sized)|intval}" style="width: 450px{if empty($value.trad)};background:#FBB{/if}"
name="{if in_array($type, array('front', 'fields'))}{$k}_{$key|md5}{else}{$k}{$key|md5}{/if}"
>{$value|regex_replace:'/"/':'&quot;'|stripslashes}</textarea>
>{$value.trad|regex_replace:'/"/':'&quot;'|stripslashes}</textarea>
{/if}
{if isset($value.use_sprintf) && $value.use_sprintf}
<a class="useSpecialSyntax" title="{l s='This expression uses a special syntax:'} {$value.use_sprintf}" style="cursor:pointer">
<img src="{$smarty.const._PS_IMG_}admin/error.png" alt="{$value.use_sprintf}" />
</a>
{/if}
</td>
</tr>
@@ -28,13 +28,6 @@
{block name="override_tpl"}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
<li>{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}</li>
</ul>
</div><br /><br />
{$tinyMCE}
{if $post_limit_exceeded}
@@ -53,6 +46,13 @@
{l s='%s at least or edit the translation file manually.' sprintf=$limit_warning['needed_limit']}
</div>
{else}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
</ul>
</div><br /><br />
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
{$toggle_button}
<input type="hidden" name="lang" value="{$lang}" />
@@ -28,18 +28,6 @@
{block name="override_tpl"}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
<li>{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}</li>
</ul>
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations}<br />
</p>
{if $post_limit_exceeded}
<div class="warn">
{if $limit_warning['error_type'] == 'suhosin'}
@@ -56,6 +44,46 @@
{l s='%s at least or edit the translation file manually.' sprintf=$limit_warning['needed_limit']}
</div>
{else}
<div class="hint" style="display:block;">
<ul style="margin-left:30px;list-style-type:disc;">
<li>{l s='Click on the titles to open fieldsets'}.</li>
<li>{l s='Some sentences to translate uses this syntax: %s...: You must let it in your translations.' sprintf='%d, %s, %1$s, %2$d'}</li>
</ul>
</div><br /><br />
<p>
{l s='Expressions to translate: %d.' sprintf=$count}<br />
{l s='Total missing expresssions: %d.' sprintf=$missing_translations}<br />
</p>
<script type="text/javascript">
$(document).ready(function(){
$('a.useSpecialSyntax').click(function(){
var syntax = $(this).find('img').attr('alt');
$('#BoxUseSpecialSyntax .syntax span').html(syntax);
$('#BoxUseSpecialSyntax').toggle(1000);
});
$('#BoxUseSpecialSyntax').click(function(){
$('#BoxUseSpecialSyntax').toggle(1000);
});
});
</script>
<div id="BoxUseSpecialSyntax">
<div class="warn">
<p class="syntax">
{l s='This expression uses this special syntax:'} <span>%d</span><br />
{l s='You must use this syntax in your tanslations. Here are several examples of use:'}
</p>
<ul>
<li><em>There are <strong>%d</strong> products</em> ("<strong>%d</strong>" {l s='will be replaced by a number'}).</li>
<li><em>List of pages in <strong>%s</strong>:</em> ("<strong>%s</strong>" {l s='will be replaced by a string'}).</li>
<li><em>Feature: <strong>%1$s</strong> (<strong>%2$d</strong> values)</em> ("<strong>n$</strong>" {l s='is used for the order of the arguments'}).</li>
</ul>
</div>
</div>
<form method="post" id="{$table}_form" action="{$url_submit}" class="form">
{$toggle_button}
<input type="hidden" name="lang" value="{$lang}" />
@@ -70,9 +98,12 @@
<h3>{l s='Module:'} <a name="{$module_name}" style="font-style:italic">{$module_name}</a></h3>
{foreach $module as $template_name => $newLang}
{if !empty($newLang)}
{$occurrences = $newLang|array_count_values}
{if isset($occurrences[''])}
{$missing_translations_module = $occurrences['']}
{assign var=occurrences value=0}
{foreach $newLang as $key => $value}
{if empty($value['trad'])}{assign var=occurrences value=$occurrences+1}{/if}
{/foreach}
{if $occurrences > 0}
{$missing_translations_module = $occurrences}
{else}
{$missing_translations_module = 0}
{/if}
@@ -90,13 +121,18 @@
{capture assign="name"}{strtolower($module_name)}_{strtolower($theme_name)}_{strtolower($template_name)}_{md5($key)}{/capture}
{if $key|strlen < $textarea_sized}
<input type="text"
style="width: 450px{if empty($value)};background:#FBB{/if}"
style="width: 450px{if empty($value.trad)};background:#FBB{/if}"
name="{$name|md5}"
value="{$value|regex_replace:'#"#':'&quot;'|stripslashes}" />
value="{$value.trad|regex_replace:'#"#':'&quot;'|stripslashes}" />
{else}
<textarea rows="{($key|strlen / $textarea_sized)|intval}"
style="width: 450px{if empty($value)};background:#FBB{/if}"
name="{$name|md5}">{$value|regex_replace:'#"#':'&quot;'|stripslashes}</textarea>
style="width: 450px{if empty($value.trad)};background:#FBB{/if}"
name="{$name|md5}">{$value.trad|regex_replace:'#"#':'&quot;'|stripslashes}</textarea>
{/if}
{if isset($value.use_sprintf) && $value.use_sprintf}
<a class="useSpecialSyntax" title="{l s='This expression uses a special syntax:'} {$value.use_sprintf}" style="cursor:pointer">
<img src="{$smarty.const._PS_IMG_}admin/error.png" alt="{$value.use_sprintf}" />
</a>
{/if}
</td>
</tr>