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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
49b38194
Commit
49b38194
authored
Aug 24, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only perform `join_message` in `validate_variable_usage`
parent
1da594d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
lib/gitlab/po_linter.rb
lib/gitlab/po_linter.rb
+8
-9
spec/lib/gitlab/po_linter_spec.rb
spec/lib/gitlab/po_linter_spec.rb
+0
-1
No files found.
lib/gitlab/po_linter.rb
View file @
49b38194
...
@@ -86,16 +86,8 @@ module Gitlab
...
@@ -86,16 +86,8 @@ module Gitlab
validate_unnamed_variables
(
errors
,
required_variables
)
validate_unnamed_variables
(
errors
,
required_variables
)
validate_translation
(
errors
,
message_id
,
required_variables
)
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
)
validate_variable_usage
(
errors
,
message_translation
,
required_variables
)
end
end
end
def
validate_translation
(
errors
,
message_id
,
used_variables
)
def
validate_translation
(
errors
,
message_id
,
used_variables
)
variables
=
fill_in_variables
(
used_variables
)
variables
=
fill_in_variables
(
used_variables
)
...
@@ -150,6 +142,13 @@ module Gitlab
...
@@ -150,6 +142,13 @@ module Gitlab
end
end
def
validate_variable_usage
(
errors
,
translation
,
required_variables
)
def
validate_variable_usage
(
errors
,
translation
,
required_variables
)
translation
=
join_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.
return
if
translation
.
empty?
found_variables
=
translation
.
scan
(
VARIABLE_REGEX
)
found_variables
=
translation
.
scan
(
VARIABLE_REGEX
)
missing_variables
=
required_variables
-
found_variables
missing_variables
=
required_variables
-
found_variables
...
...
spec/lib/gitlab/po_linter_spec.rb
View file @
49b38194
...
@@ -226,7 +226,6 @@ describe Gitlab::PoLinter do
...
@@ -226,7 +226,6 @@ describe Gitlab::PoLinter do
expect
(
errors
).
to
include
(
'Failure translating to en with []: broken'
)
expect
(
errors
).
to
include
(
'Failure translating to en with []: broken'
)
end
end
it
"adds an error when trying to translate with incorrect variables when using unnamed variables"
do
it
"adds an error when trying to translate with incorrect variables when using unnamed variables"
do
errors
=
[]
errors
=
[]
...
...
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