Permalink
Browse files

Differentiate empty from missing strings (#768)

* Remove padding on error labels

* Differentiate empty from missing strings

* Fix message in onestring view for empty strings

* Fix php-cs error

* Don't add empty strings to TMX for missing entities
  • Loading branch information...
flodolo authored and TheoChevalier committed Jul 12, 2016
1 parent 6468f1d commit 64dda7a9256ff0537b360980b2756a0df03d4548
@@ -162,7 +162,7 @@ public static function getRepositorySearchResults($entities, $array_strings)
foreach ($search_results as $entity => $set) {
// We only want results for which we have a translation
if ($set[1]) {
if ($set[1] != '@@missing@@') {
$output[$entity] = [
$clean_string($set[0]) => $clean_string($set[1]),
];
@@ -181,9 +181,9 @@ public static function getRepositorySearchResults($entities, $array_strings)
*/
public static function getStringFromEntity($entity, $strings)
{
return isset($strings[$entity]) && $strings[$entity] != ''
return isset($strings[$entity])
? $strings[$entity]
: false;
: '@@missing@@';
}
/**
@@ -380,17 +380,21 @@ public static function resultsTable($search_object, $search_results, $page)
}
// If there is no target_string, display an error, otherwise display the string + meta links
if (! $target_string) {
if ($target_string == '@@missing@@') {
$target_string = '<em class="error">Warning: Missing string</em>';
} elseif (! $target_string) {
$target_string = '<em class="error">Warning: Empty string</em>';
} else {
$meta_target = "
<span class='clipboard' data-clipboard-target='#{$clipboard_target_string}' alt='Copy to clipboard'><img src='/img/copy_icon_black_18x18.png'></span>
{$error_message}";
}
// If there is no target_string2, display an error, otherwise display the string + meta links
if (! $target_string2) {
if ($target_string2 == '@@missing@@') {
$target_string2 = '<em class="error">Warning: Missing string</em>';
} elseif (! $target_string2) {
$target_string2 = '<em class="error">Warning: Empty string</em>';
} else {
$meta_target2 = "<span class='clipboard' data-clipboard-target='#{$clipboard_target_string2}' alt='Copy to clipboard'><img src='/img/copy_icon_black_18x18.png'></span>";
}
@@ -145,11 +145,12 @@ def create_tmx_content(reference_repo, locale_repo, dirs):
get_strings(l10nPackage_locale, directory, strings_locale)
for entity in strings_reference:
# Append string to tmx_content, using the format of a PHP array
# element
# element, but only if there's a translation available
translation = escape(
strings_locale.get(entity, '')).encode('utf-8')
tmx_content.append("'{0}' => '{1}'".format(
entity.encode('utf-8'), translation))
strings_locale.get(entity, '@@missing@@')).encode('utf-8')
if translation != '@@missing@@':
tmx_content.append("'{0}' => '{1}'".format(
entity.encode('utf-8'), translation))
tmx_content.sort()
return tmx_content
@@ -179,8 +180,7 @@ def main():
args.reference_repo, args.locale_repo, args.repository
)
tmx_content = create_tmx_content(
args.reference_repo, args.locale_repo, dirs
)
args.reference_repo, args.locale_repo, dirs)
# Store the actual file on disk
filename_locale = os.path.join(
View
@@ -34,7 +34,7 @@
" <th><a href='#{$locale}'>{$locale}</a></th>\n";
if (! $translation) {
echo " <td><em class='error'>Warning: Missing string</em></td><td></td>\n";
echo " <td><em class='error'>Warning: Empty string</em></td><td></td>\n";
} else {
echo " <td lang='#{$locale}' {$rtl_support} >" . Utils::secureText($translation) . "</td>\n" .
" <td><a class='onestring_search' href='{$search_link}' title='Search for the entity in this locale'>🔍</a></td>\n";
@@ -51,7 +51,7 @@
<fieldset>
<label>Repository</label>
<select name="product" id="product_select">
' . $product_selector . '
' . $product_selector . '
</select>
</fieldset>
<input type="submit" value="Go" alt="Go" />
@@ -30,7 +30,7 @@
// Escape strings for HTML display
$bz_target_string = $target_string = isset($tmx_target[$entity])
? Utils::secureText($tmx_target[$entity])
: '';
: '@@missing@@';
// Highlight non-breaking spaces only after strings have been escaped
$target_string = str_replace(' ', '<span class="highlight-gray"> </span>', $target_string);
@@ -63,8 +63,10 @@
. '">&lt;report a bug&gt;</a>';
// If there is no target_string2, display an error
if (! $target_string2) {
if ($target_string2 == '@@missing@@') {
$target_string2 = '<em class="error">Warning: Missing string</em>';
} elseif (! $target_string2) {
$target_string2 = '<em class="error">Warning: Empty string</em>';
}
$extra_column_rows = "
@@ -124,8 +126,10 @@
}
// If there is no target_string, display an error, otherwise display the string + meta links
if (! $target_string) {
if ($target_string == '@@missing@@') {
$target_string = '<em class="error">Warning: Missing string</em>';
} elseif (! $target_string) {
$target_string = '<em class="error">Warning: Empty string</em>';
} else {
$meta_target = "
{$error_message}
@@ -134,12 +134,12 @@ public function getStringFromEntityDP()
[
'browser/pdfviewer/viewer.properties:last_page.label',
['entity.is.not.found' => 'Aller à la dernière page'],
false,
'@@missing@@',
],
[
'browser/pdfviewer/viewer.properties:last_page.label',
['browser/pdfviewer/viewer.properties:last_page.label' => ''],
false,
'',
],
];
}
@@ -347,10 +347,6 @@ td em.error {
color: #f00;
}
td em.error {
padding-left: 6px;
}
td a.tag {
font-size: 75%;
color: #808080;

0 comments on commit 64dda7a

Please sign in to comment.