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
e40978f1
Commit
e40978f1
authored
Nov 10, 2020
by
David Barr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve rake gettext:lint performance
parent
f82c3f2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
lib/gitlab/i18n/po_linter.rb
lib/gitlab/i18n/po_linter.rb
+8
-10
spec/lib/gitlab/i18n/po_linter_spec.rb
spec/lib/gitlab/i18n/po_linter_spec.rb
+3
-2
No files found.
lib/gitlab/i18n/po_linter.rb
View file @
e40978f1
...
...
@@ -24,7 +24,9 @@ module Gitlab
return
'PO-syntax errors'
=>
[
parse_error
]
end
validate_entries
Gitlab
::
I18n
.
with_locale
(
locale
)
do
validate_entries
end
end
def
parse_po
...
...
@@ -156,12 +158,10 @@ module Gitlab
end
def
validate_translation
(
errors
,
entry
)
Gitlab
::
I18n
.
with_locale
(
locale
)
do
if
entry
.
has_plural?
translate_plural
(
entry
)
else
translate_singular
(
entry
)
end
if
entry
.
has_plural?
translate_plural
(
entry
)
else
translate_singular
(
entry
)
end
# `sprintf` could raise an `ArgumentError` when invalid passing something
...
...
@@ -230,9 +230,7 @@ module Gitlab
# This calls the C function that defines the pluralization rule, it can
# return a boolean (`false` represents 0, `true` represents 1) or an integer
# that specifies the plural form to be used for the given number
pluralization_result
=
Gitlab
::
I18n
.
with_locale
(
locale
)
do
FastGettext
.
pluralisation_rule
.
call
(
counter
)
end
pluralization_result
=
FastGettext
.
pluralisation_rule
.
call
(
counter
)
case
pluralization_result
when
false
...
...
spec/lib/gitlab/i18n/po_linter_spec.rb
View file @
e40978f1
...
...
@@ -461,9 +461,10 @@ RSpec.describe Gitlab::I18n::PoLinter do
fake_metadata
=
double
allow
(
fake_metadata
).
to
receive
(
:forms_to_test
).
and_return
(
4
)
allow
(
linter
).
to
receive
(
:metadata_entry
).
and_return
(
fake_metadata
)
allow
(
linter
).
to
receive
(
:locale
).
and_return
(
'pl_PL'
)
numbers
=
linter
.
numbers_covering_all_plurals
numbers
=
Gitlab
::
I18n
.
with_locale
(
'pl_PL'
)
do
linter
.
numbers_covering_all_plurals
end
expect
(
numbers
).
to
contain_exactly
(
0
,
1
,
2
)
end
...
...
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