Skip to content

Commit 18f099b

Browse files
authored
i18n-tasks (#243)
* i18n-tasks https://github.com/glebm/i18n-tasks * i18n-tasks https://github.com/glebm/i18n-tasks * Update en.yml * Update i18n_test.rb
1 parent 8a26eec commit 18f099b

File tree

5 files changed

+122
-59
lines changed

5 files changed

+122
-59
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ group :development do
5858
# Use console on exceptions pages [https://github.com/rails/web-console]
5959
gem "web-console"
6060
gem "nested_scaffold", github: "yshmarov/nested_scaffold", branch: "master"
61+
gem "i18n-tasks"
6162
end
6263

6364
group :test do

Gemfile.lock

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,21 @@ GEM
145145
raabro (~> 1.4)
146146
globalid (1.2.1)
147147
activesupport (>= 6.1)
148+
highline (3.1.2)
149+
reline
148150
i18n (1.14.7)
149151
concurrent-ruby (~> 1.0)
152+
i18n-tasks (1.0.15)
153+
activesupport (>= 4.0.2)
154+
ast (>= 2.1.0)
155+
erubi
156+
highline (>= 2.0.0)
157+
i18n
158+
parser (>= 3.2.2.1)
159+
rails-i18n
160+
rainbow (>= 2.2.2, < 4.0)
161+
ruby-progressbar (~> 1.8, >= 1.8.1)
162+
terminal-table (>= 1.5.1)
150163
importmap-rails (2.1.0)
151164
actionpack (>= 6.0.0)
152165
activesupport (>= 6.0.0)
@@ -290,6 +303,9 @@ GEM
290303
rails-html-sanitizer (1.6.2)
291304
loofah (~> 2.21)
292305
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
306+
rails-i18n (8.0.1)
307+
i18n (>= 0.7, < 2)
308+
railties (>= 8.0.0, < 9)
293309
railties (8.0.2)
294310
actionpack (= 8.0.2)
295311
activesupport (= 8.0.2)
@@ -389,6 +405,8 @@ GEM
389405
tailwindcss-ruby (4.1.6-arm64-darwin)
390406
tailwindcss-ruby (4.1.6-x86_64-darwin)
391407
tailwindcss-ruby (4.1.6-x86_64-linux-gnu)
408+
terminal-table (4.0.0)
409+
unicode-display_width (>= 1.1.1, < 4)
392410
thor (1.3.2)
393411
thruster (0.1.13)
394412
thruster (0.1.13-aarch64-linux)
@@ -442,6 +460,7 @@ DEPENDENCIES
442460
devise (~> 4.9)
443461
devise_invitable (~> 2.0)
444462
erb_lint
463+
i18n-tasks
445464
importmap-rails
446465
inline_svg (~> 1.9)
447466
jbuilder

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ bundle exec erb_lint --lint-all -a
275275
bundle exec rubocop -A
276276
```
277277

278+
```bash
279+
# Alphabetically sort i18n keys
280+
i18n-tasks normalize
281+
```
282+
278283
# ✨ Contributors
279284

280285
<a href="https://avohq.io/contributors">

config/locales/en.yml

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,65 @@ en:
1111
models:
1212
membership: Member
1313
organization: Organization
14+
discovers:
15+
show:
16+
actions:
17+
accept_invitation: Accept invitation
18+
join: Join
19+
open: Open
20+
request_to_join: Request to join
21+
waiting_for_approval: Waiting for approval
22+
page_title: Choose your next organization
23+
title: Discover
24+
invitations:
25+
approve:
26+
success: Invitation approved
27+
buttons:
28+
approve: Join
29+
reject: Reject
30+
errors:
31+
not_found: Invitation not found
32+
index:
33+
title: Pending invitations
34+
reject:
35+
success: Invitation rejected
36+
membership_requests:
37+
approve:
38+
success: Membership request approved
39+
buttons:
40+
approve: Approve
41+
reject: Reject
42+
errors:
43+
already_participant: You're already a member of this organization
44+
already_requested: You have already requested access to this organization
45+
not_found: Membership request not found
46+
index:
47+
page_title: Pending membership requests for %{organization}
48+
title: Membership Requests
49+
reject:
50+
success: Membership request rejected
51+
success: Requested access successfully
1452
organizations:
1553
create:
1654
success: Organization created
1755
destroy:
1856
success: Organization destroyed
1957
edit:
2058
title: Edit organization
59+
errors:
60+
not_found: Organization not found
2161
index:
2262
title: My organizations
63+
invitations:
64+
buttons:
65+
cancel: Cancel invitation
66+
destroy:
67+
success: Invitation cancelled
68+
errors:
69+
not_found: Invitation not found
70+
index:
71+
page_title: Pending invitations for %{organization}
72+
title: Pending invitations
2373
memberships:
2474
create:
2575
success: "%{email} invited"
@@ -28,12 +78,12 @@ en:
2878
user_removed_from_organization: User removed from organization
2979
you_have_left_the_organization: You have left the organization
3080
index:
31-
title: Teammates
3281
access_settings:
33-
title: Access Settings
34-
privacy: Privacy type
3582
invitations: Pending invitations
83+
privacy: Privacy type
3684
requests_to_join_organization: Pending requests to join organization
85+
title: Access Settings
86+
title: Teammates
3787
new:
3888
title: Invite teammate
3989
update:
@@ -69,58 +119,11 @@ en:
69119
update:
70120
success: Ownership transferred
71121
update:
72-
success: Organization updated
73122
error: An error occurred while updating the organization
74-
invitations:
75-
index:
76-
title: Pending invitations
77-
page_title: Pending invitations for %{organization}
78-
destroy:
79-
success: Invitation cancelled
80-
buttons:
81-
cancel: Cancel invitation
82-
errors:
83-
not_found: Invitation not found
84-
errors:
85-
not_found: Organization not found
86-
discovers:
87-
show:
88-
title: Discover
89-
page_title: Choose your next organization
90-
actions:
91-
join: Join
92-
request_to_join: Request to join
93-
open: Open
94-
waiting_for_approval: Waiting for approval
95-
accept_invitation: Accept invitation
96-
invitations:
97-
index:
98-
title: Pending invitations
99-
approve:
100-
success: Invitation approved
101-
reject:
102-
success: Invitation rejected
103-
buttons:
104-
approve: Join
105-
reject: Reject
106-
errors:
107-
not_found: Invitation not found
108-
membership_requests:
109-
index:
110-
title: Membership Requests
111-
page_title: Pending membership requests for %{organization}
112-
buttons:
113-
approve: Approve
114-
reject: Reject
115-
success: Requested access successfully
116-
approve:
117-
success: Membership request approved
118-
reject:
119-
success: Membership request rejected
120-
errors:
121-
not_found: Membership request not found
122-
already_requested: You have already requested access to this organization
123-
already_participant: You're already a member of this organization
123+
success: Organization updated
124+
routes:
125+
memberships: teammates
126+
organizations: organizations
124127
shared:
125128
actions:
126129
cancel: Cancel
@@ -133,20 +136,17 @@ en:
133136
not_subscribed: You need to subscribe to access this page.
134137
rate_limit: Try again later.
135138
navigation:
139+
discover: Discover Organizations
136140
edit_profile: Edit profile
137141
login: Log in
138142
logout: Log out
143+
pending_invitations: Pending invitations
139144
register: Register
140145
select_organization: Select organization
141-
pending_invitations: Pending invitations
142-
discover: Discover Organizations
143146
static:
144147
pricing:
145148
title: Pricing
146149
privacy:
147150
title: Privacy
148151
terms:
149152
title: Terms
150-
routes:
151-
organizations: organizations
152-
memberships: teammates

test/i18n_test.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
require "i18n/tasks"
4+
5+
class I18nTest < ActiveSupport::TestCase
6+
def setup
7+
@i18n = I18n::Tasks::BaseTask.new
8+
end
9+
10+
def test_no_missing_keys
11+
skip
12+
missing_keys = @i18n.missing_keys
13+
assert_empty missing_keys,
14+
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
15+
end
16+
17+
def test_no_unused_keys
18+
skip
19+
unused_keys = @i18n.unused_keys
20+
assert_empty unused_keys,
21+
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
22+
end
23+
24+
def test_files_are_normalized
25+
non_normalized = @i18n.non_normalized_paths
26+
error_message = "The following files need to be normalized:\n" \
27+
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
28+
"Please run `i18n-tasks normalize' to fix"
29+
assert_empty non_normalized, error_message
30+
end
31+
32+
def test_no_inconsistent_interpolations
33+
inconsistent_interpolations = @i18n.inconsistent_interpolations
34+
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
35+
"Please run `i18n-tasks check-consistent-interpolations' to show them"
36+
assert_empty inconsistent_interpolations, error_message
37+
end
38+
end

0 commit comments

Comments
 (0)