Skip to content

Commit

Permalink
feat: check {variables} are kept in translations (#6709)
Browse files Browse the repository at this point in the history
* feat: check {variables} are kept in translations #6702
* Update t/lang.t
* chore: fix turkish translation

Co-authored-by: Alex Garel <alex@garel.org>
  • Loading branch information
stephanegigandet and alexgarel committed May 18, 2022
1 parent d71980a commit fdbd7f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion po/common/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4187,7 +4187,7 @@ msgstr "Bazı içerikler tanınamadı."
# variable names between { } must not be translated
msgctxt "f_move_data_and_photos_to_main_language"
msgid "Move all data and selected photos in {language} to the main language of the product: {main_language}"
msgstr "(dilindeki) seçilen fotoğrafları ve tüm verileri ürünün ana diline yerleştirin(ana dil)"
msgstr "Tüm verileri ve seçilen fotoğrafları {language} ürünün ana diline taşıyın: {main_language}"

msgctxt "move_data_and_photos_to_main_language_replace"
msgid "Replace existing values and selected photos"
Expand Down
15 changes: 15 additions & 0 deletions t/lang.t
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ sub test_logo_exists {
test_logo_exists('logo');
test_logo_exists('logo2x');

# Test that {variables} are kept in translations

foreach my $stringid (sort keys %Lang) {
while ($Lang{$stringid}{en} =~ /\{([^}]+)\}/g) {
my $variable = $1;
foreach my $l (sort keys %{$Lang{$stringid}}) {
# Note: the if below is added so that we don't have thousands of tests reported in the output
# only non passing tests are tested with like() and reported.
if ($Lang{$stringid}{$l} !~ /\{$variable\}/) {
like($Lang{$stringid}{$l}, qr/\{$variable\}/, "$stringid translation in $l contains {$variable}");
}
}
}
}

done_testing();

0 comments on commit fdbd7f3

Please sign in to comment.