Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
973c6979
Commit
973c6979
authored
Aug 22, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for languages without plurals
parent
c34cf3a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletion
+75
-1
lib/gitlab/po_linter.rb
lib/gitlab/po_linter.rb
+9
-1
spec/fixtures/multiple_plurals.po
spec/fixtures/multiple_plurals.po
+26
-0
spec/fixtures/no_plurals.po
spec/fixtures/no_plurals.po
+24
-0
spec/lib/gitlab/po_linter_spec.rb
spec/lib/gitlab/po_linter_spec.rb
+16
-0
No files found.
lib/gitlab/po_linter.rb
View file @
973c6979
...
@@ -66,7 +66,11 @@ module Gitlab
...
@@ -66,7 +66,11 @@ module Gitlab
def
validate_variables
(
errors
,
entry
)
def
validate_variables
(
errors
,
entry
)
if
entry
[
:msgid_plural
].
present?
if
entry
[
:msgid_plural
].
present?
validate_variables_in_message
(
errors
,
entry
[
:msgid
],
entry
[
'msgstr[0]'
])
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
else
validate_variables_in_message
(
errors
,
entry
[
:msgid
],
entry
[
:msgstr
])
validate_variables_in_message
(
errors
,
entry
[
:msgid
],
entry
[
:msgstr
])
end
end
...
@@ -80,6 +84,10 @@ module Gitlab
...
@@ -80,6 +84,10 @@ module Gitlab
validate_translation
(
errors
,
message_id
,
required_variables
)
validate_translation
(
errors
,
message_id
,
required_variables
)
message_translation
=
join_message
(
message_translation
)
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?
unless
message_translation
.
empty?
validate_variable_usage
(
errors
,
message_translation
,
required_variables
)
validate_variable_usage
(
errors
,
message_translation
,
required_variables
)
end
end
...
...
spec/fixtures/multiple_plurals.po
0 → 100644
View file @
973c6979
# 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"
spec/fixtures/no_plurals.po
0 → 100644
View file @
973c6979
# 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個のコミット"
spec/lib/gitlab/po_linter_spec.rb
View file @
973c6979
...
@@ -65,6 +65,22 @@ describe Gitlab::PoLinter do
...
@@ -65,6 +65,22 @@ describe Gitlab::PoLinter do
is_expected
.
to
be_empty
is_expected
.
to
be_empty
end
end
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
end
describe
'#parse_po'
do
describe
'#parse_po'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment