BigW Consortium Gitlab

Commit 973c6979 by Bob Van Landuyt

Add spec for languages without plurals

parent c34cf3a9
......@@ -66,7 +66,11 @@ module Gitlab
def validate_variables(errors, entry)
if entry[:msgid_plural].present?
validate_variables_in_message(errors, entry[:msgid], entry['msgstr[0]'])
validate_variables_in_message(errors, entry[:msgid_plural], entry['msgstr[1]'])
# Validate all plurals
entry.keys.select { |key_name| key_name =~ /msgstr\[[1-9]\]/ }.each do |plural_key|
validate_variables_in_message(errors, entry[:msgid_plural], entry[plural_key])
end
else
validate_variables_in_message(errors, entry[:msgid], entry[:msgstr])
end
......@@ -80,6 +84,10 @@ module Gitlab
validate_translation(errors, message_id, required_variables)
message_translation = join_message(message_translation)
# We don't need to validate when the message is empty.
# Translations could fallback to the default, or we could be validating a
# language that does not have plurals.
unless message_translation.empty?
validate_variable_usage(errors, message_translation, required_variables)
end
......
# Arthur Charron <arthur.charron@hotmail.fr>, 2017. #zanata
# Huang Tao <htve@outlook.com>, 2017. #zanata
# Kohei Ota <inductor@kela.jp>, 2017. #zanata
# Taisuke Inoue <taisuke.inoue.jp@gmail.com>, 2017. #zanata
# Takuya Noguchi <takninnovationresearch@gmail.com>, 2017. #zanata
# YANO Tethurou <tetuyano+zana@gmail.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-08-06 11:23-0400\n"
"Last-Translator: Taisuke Inoue <taisuke.inoue.jp@gmail.com>\n"
"Language-Team: Japanese \"Language-Team: Russian (https://translate.zanata.org/"
"project/view/GitLab)\n"
"Language: ja\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=3; plural=n\n"
msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] "%d個のコミット"
msgstr[1] "%d個のコミット"
msgstr[2] "missing a variable"
# Arthur Charron <arthur.charron@hotmail.fr>, 2017. #zanata
# Huang Tao <htve@outlook.com>, 2017. #zanata
# Kohei Ota <inductor@kela.jp>, 2017. #zanata
# Taisuke Inoue <taisuke.inoue.jp@gmail.com>, 2017. #zanata
# Takuya Noguchi <takninnovationresearch@gmail.com>, 2017. #zanata
# YANO Tethurou <tetuyano+zana@gmail.com>, 2017. #zanata
msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-08-06 11:23-0400\n"
"Last-Translator: Taisuke Inoue <taisuke.inoue.jp@gmail.com>\n"
"Language-Team: Japanese \"Language-Team: Russian (https://translate.zanata.org/"
"project/view/GitLab)\n"
"Language: ja\n"
"X-Generator: Zanata 3.9.6\n"
"Plural-Forms: nplurals=1; plural=0\n"
msgid "%d commit"
msgid_plural "%d commits"
msgstr[0] "%d個のコミット"
......@@ -65,6 +65,22 @@ describe Gitlab::PoLinter do
is_expected.to be_empty
end
end
context 'with missing plurals' do
let(:po_path) { 'spec/fixtures/no_plurals.po' }
it 'has no errors' do
is_expected.to be_empty
end
end
context 'with multiple plurals' do
let(:po_path) { 'spec/fixtures/multiple_plurals.po' }
it 'has no errors' do
is_expected.not_to be_empty
end
end
end
describe '#parse_po' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment