Skip to content

Commit

Permalink
Remove consistency section in Gaia view
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo committed Mar 5, 2016
1 parent 53cea4d commit a7937db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 52 deletions.
4 changes: 2 additions & 2 deletions app/models/consistency.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
$strings_number = 0;

$source_strings = Utils::getRepoStrings($reference_locale, $repo);
// Ignore empty strings in translations
$target_strings = array_filter(Utils::getRepoStrings($locale, $repo));
// Remove blanks strings. Using 'strlen' to avoid filtering out strings set to 0
$target_strings = array_filter(Utils::getRepoStrings($locale, $repo), 'strlen');

if (! empty($source_strings)) {
// Remove known problematic strings
Expand Down
56 changes: 7 additions & 49 deletions app/views/gaia.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@
}

$sections = [
'translation_status' => 'Translation Status',
'diverging_strings' => 'Diverging Strings',
'translation_consistency' => 'Translation Consistency',
'changed_english' => 'String Changes in English',
'new_strings' => 'New Strings',
'translation_status' => 'Translation Status',
'diverging_strings' => 'Diverging Strings',
'changed_english' => 'String Changes in English',
'new_strings' => 'New Strings',
];

?>
Expand Down Expand Up @@ -134,6 +133,8 @@
foreach ($sections as $anchor_name => $section_title) {
print " <li><a href='#{$anchor_name}'>{$section_title}</a></li>\n";
}
// Adding a manual link for consistency (to the specific view)
print " <li>Translation consistency for <a href='/consistency/?locale={$locale}&repo={$repo1}'>{$repos_nice_names[$repo1]}</a> or <a href='/consistency/?locale={$locale}&repo={$repo2}'>{$repos_nice_names[$repo2]}</a></li>\n";
print "</ul>\n";

print $anchor_title('translation_status');
Expand All @@ -157,7 +158,7 @@
$temp[] = $repo[$k];
}

// Remove blanks
// Remove blanks strings. Using 'strlen' to avoid filtering out strings set to 0
$temp = array_filter($temp, 'strlen');

// Remove duplicates
Expand Down Expand Up @@ -209,49 +210,6 @@
'diverging'
);

$english_repo = "{$repo1}-en-US";
$l10n_repo = $repo1;
$duplicated_strings_english = Consistency::findDuplicates($strings[$english_repo]);
$duplicated_strings_translation = Consistency::findDuplicates($strings[$l10n_repo]);

// Filter English duplicates before comparing them with the localization
$duplicated_strings_english = Consistency::filterStrings($duplicated_strings_english, $l10n_repo);

// Get the strings duplicated in English but not in the localization
$missing_duplicates = array_diff_key($duplicated_strings_english, $duplicated_strings_translation);

$inconsistent_translations = [];
foreach ($duplicated_strings_english as $key => $value) {
if (in_array($value, $missing_duplicates)) {
// Store inconsistency only if there's a translation available
if (isset($strings[$l10n_repo][$key])) {
$inconsistent_translations[] = [
'key' => $key,
'en-US' => $strings[$english_repo][$key],
'l10n' => $strings[$repo1][$key],
];
}
}
}

if (count($inconsistent_translations) > 0) {
$inconsistent_results = "\n<table><tr><th>Label</th><th>English</th><th>Translation</th></tr>";
foreach ($inconsistent_translations as $inconsistent_translation) {
$inconsistent_results .= "<tr>
<td>" . ShowResults::formatEntity($inconsistent_translation['key']) . "</td>
<td>" . Utils::secureText($inconsistent_translation['en-US']) . "</td>
<td>" . Utils::secureText($inconsistent_translation['l10n']) . "</td>
</tr>\n";
}
$inconsistent_results .= "</table>\n";
} else {
$inconsistent_results = "<p>No inconsistent translations found.</p>";
}

print $anchor_title('translation_consistency');
print "<p class='subtitle'>Analysis of translation consistency in {$repos_nice_names[$repo1]}.</p>";
print $inconsistent_results;

// Changes in en-US
$englishchanges = [$repo1, $repo2];

Expand Down
2 changes: 1 addition & 1 deletion web/style/transvision.css
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ fieldset {

#gaia_views_list {
margin: 10px auto;
width: 200px;
width: 350px;
}

#gaia h3 {
Expand Down

0 comments on commit a7937db

Please sign in to comment.