Skip to content

Commit 1b92c99

Browse files
authored
Merge pull request #141 from JudahSan/data/populate-locales
Internationalize Views Using Existing I18n Setup
2 parents 72bcc71 + d5a525e commit 1b92c99

29 files changed

+1050
-199
lines changed

app/helpers/chapters_helper.rb

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,95 @@
22

33
module ChaptersHelper
44
ACTIVITIES = [
5-
{ image: 'activities_local_meetups.png', title: 'Local meetups' },
6-
{ image: 'activities_local_conferences.png', title: 'conferences' },
7-
{ image: 'activities_local_programming.png', title: 'programming' },
8-
{ image: 'activities_local_workshops.png', title: 'workshops' },
9-
{ image: 'activities_local_hackathons.png', title: 'hackathons' }
5+
{ image: 'activities_local_meetups.png', title_key: 'activities.meetups' },
6+
{ image: 'activities_local_conferences.png', title_key: 'activities.conferences' },
7+
{ image: 'activities_local_programming.png', title_key: 'activities.programming' },
8+
{ image: 'activities_local_workshops.png', title_key: 'activities.workshops' },
9+
{ image: 'activities_local_hackathons.png', title_key: 'activities.hackathons' }
1010
].freeze
1111

1212
CHAPTERS = [
13-
{ country: 'Kenya', image: 'country_kenya.png', alt: 'Nairuby' },
14-
{ country: 'Rwanda', image: 'country_rwanda.png', alt: 'ARC_Rwanda' },
15-
{ country: 'Tanzania', image: 'country_tanzania.png', alt: 'ARC_Tanzania' },
16-
{ country: 'Uganda', image: 'country_uganda.png', alt: 'ARC_Uganda' }
13+
{ country_key: 'chapters.countries.kenya', image: 'country_kenya.png', alt_key: 'chapters.alt_text.nairuby' },
14+
{ country_key: 'chapters.countries.rwanda', image: 'country_rwanda.png', alt_key: 'chapters.alt_text.arc_rwanda' },
15+
{ country_key: 'chapters.countries.tanzania', image: 'country_tanzania.png',
16+
alt_key: 'chapters.alt_text.arc_tanzania' },
17+
{ country_key: 'chapters.countries.uganda', image: 'country_uganda.png', alt_key: 'chapters.alt_text.arc_uganda' }
1718
].freeze
1819

1920
FEATURED_SPONSORS = [
20-
{ image: 'sponsors/current/solutech_official.svg', link: 'https://solutech.co.ke', alt: 'Solutech' },
21-
{ image: 'sponsors/current/app_signal.png', link: 'https://www.appsignal.com', alt: 'App Signal' },
22-
{ image: 'sponsors/current/ruby_central.png', link: 'https://rubycentral.org/', alt: 'Ruby Central' },
23-
{ image: 'sponsors/current/kopo_kopo.png', link: 'https://kopokopo.co.ke', alt: 'Kopo Kopo' },
24-
{ image: 'sponsors/current/finplus.png', link: 'https://finplusgroup.com', alt: 'Finplus Group' },
25-
{ image: 'sponsors/current/typesense-logo.png', link: 'https://typesense.org/', alt: 'Typesense' },
26-
{ image: 'sponsors/current/daystar.png', link: 'https://www.daystar.ac.ke/', alt: 'Daystar' },
27-
{ image: 'sponsors/current/prosper.png', link: 'https://www.prosperhedge.com/', alt: 'Prosper Hedge' },
28-
{ image: 'sponsors/current/gurzu.png', link: 'https://gurzu.com/', alt: 'Gurzu' },
29-
{ image: 'sponsors/current/must-company.png', link: 'https://must.company/', alt: 'Must Company' }
21+
{ image: 'sponsors/current/solutech_official.svg', link: 'https://solutech.co.ke',
22+
alt_key: 'sponsors.current.solutech' },
23+
{ image: 'sponsors/current/app_signal.png', link: 'https://www.appsignal.com',
24+
alt_key: 'sponsors.current.app_signal' },
25+
{ image: 'sponsors/current/ruby_central.png', link: 'https://rubycentral.org/',
26+
alt_key: 'sponsors.current.ruby_central' },
27+
{ image: 'sponsors/current/kopo_kopo.png', link: 'https://kopokopo.co.ke', alt_key: 'sponsors.current.kopo_kopo' },
28+
{ image: 'sponsors/current/finplus.png', link: 'https://finplusgroup.com', alt_key: 'sponsors.current.finplus' },
29+
{ image: 'sponsors/current/typesense-logo.png', link: 'https://typesense.org/',
30+
alt_key: 'sponsors.current.typesense' },
31+
{ image: 'sponsors/current/daystar.png', link: 'https://www.daystar.ac.ke/', alt_key: 'sponsors.current.daystar' },
32+
{ image: 'sponsors/current/prosper.png', link: 'https://www.prosperhedge.com/',
33+
alt_key: 'sponsors.current.prosper' },
34+
{ image: 'sponsors/current/gurzu.png', link: 'https://gurzu.com/', alt_key: 'sponsors.current.gurzu' },
35+
{ image: 'sponsors/current/must-company.png', link: 'https://must.company/', alt_key: 'sponsors.current.must_company' }
3036
].freeze
3137

3238
PREVIOUS_SPONSORS = [
33-
{ image: 'sponsors/previous/shopify.webp', link: 'https://www.shopify.com/', alt: 'Shopify' },
34-
{ image: 'sponsors/previous/microverse.png', link: 'https://www.microverse.org/', alt: 'Microverse' },
35-
{ image: 'sponsors/previous/planet_argon.png', link: 'https://www.planetargon.com', alt: 'Planet Argon' },
36-
{ image: 'sponsors/previous/nairobits.png', link: 'https://www.nairobits.com/', alt: 'Nairobits' },
37-
{ image: 'sponsors/previous/turing.png', link: 'https://www.turing.com/', alt: 'Turing' },
38-
{ image: 'sponsors/previous/kwara.png', link: 'https://kwara.com/', alt: 'Kwara' },
39-
{ image: 'sponsors/previous/ihub.png', link: 'https://ihub.co.ke/', alt: 'iHub, Nairobi' },
40-
{ image: 'sponsors/previous/friendly_rb.jpg', link: 'https://friendlyrb.com/', alt: 'FriendlyRB' },
41-
{ image: 'sponsors/previous/kca.png', link: 'https://www.kcau.ac.ke', alt: 'KCA University' },
42-
{ image: 'sponsors/previous/andela.png', link: 'https://andela.com/', alt: 'Andela' }
39+
{ image: 'sponsors/previous/shopify.webp', link: 'https://www.shopify.com/', alt_key: 'sponsors.previous.shopify' },
40+
{ image: 'sponsors/previous/microverse.png', link: 'https://www.microverse.org/',
41+
alt_key: 'sponsors.previous.microverse' },
42+
{ image: 'sponsors/previous/planet_argon.png', link: 'https://www.planetargon.com',
43+
alt_key: 'sponsors.previous.planet_argon' },
44+
{ image: 'sponsors/previous/nairobits.png', link: 'https://www.nairobits.com/',
45+
alt_key: 'sponsors.previous.nairobits' },
46+
{ image: 'sponsors/previous/turing.png', link: 'https://www.turing.com/', alt_key: 'sponsors.previous.turing' },
47+
{ image: 'sponsors/previous/kwara.png', link: 'https://kwara.com/', alt_key: 'sponsors.previous.kwara' },
48+
{ image: 'sponsors/previous/ihub.png', link: 'https://ihub.co.ke/', alt_key: 'sponsors.previous.ihub' },
49+
{ image: 'sponsors/previous/friendly_rb.jpg', link: 'https://friendlyrb.com/',
50+
alt_key: 'sponsors.previous.friendly_rb' },
51+
{ image: 'sponsors/previous/kca.png', link: 'https://www.kcau.ac.ke', alt_key: 'sponsors.previous.kca' },
52+
{ image: 'sponsors/previous/andela.png', link: 'https://andela.com/', alt_key: 'sponsors.previous.andela' }
4353
].freeze
4454

4555
SOCIALS = [
46-
{ alt: 'ARC Twitter', link: 'https://twitter.com/ruby_african', image: 'brands_twitter.png', show: true },
47-
{ alt: 'ARC telegram', link: '#', image: 'brands_telegram.png',
56+
{ alt_key: 'social_media.twitter', link: 'https://twitter.com/ruby_african', image: 'brands_twitter.png',
57+
show: true },
58+
{ alt_key: 'social_media.telegram', link: '#', image: 'brands_telegram.png',
4859
show: FeatureFlag.find_by(name: 'telegram')&.enabled },
49-
{ alt: 'ARC facebook', link: 'https://www.facebook.com/rubycommunity.africa', image: 'brands_facebook.png',
60+
{ alt_key: 'social_media.facebook', link: 'https://www.facebook.com/rubycommunity.africa',
61+
image: 'brands_facebook.png',
5062
show: true },
51-
{ alt: 'ARC Instagram', link: '#', image: 'brands_instagram.png', show: true },
52-
{ alt: 'ARC LinkedIn', link: 'https://www.linkedin.com/company/african-ruby-community/',
63+
{ alt_key: 'social_media.instagram', link: '#', image: 'brands_instagram.png', show: true },
64+
{ alt_key: 'social_media.linkedin', link: 'https://www.linkedin.com/company/african-ruby-community/',
5365
image: 'brands_linkedin.png', show: true },
54-
{ alt: 'ARC Github', link: 'https://github.com/nairuby', image: 'brands_github.png', show: true }
66+
{ alt_key: 'social_media.github', link: 'https://github.com/nairuby', image: 'brands_github.png', show: true }
5567
].freeze
5668

5769
def activities
58-
ACTIVITIES
70+
ACTIVITIES.map do |activity|
71+
activity.merge(title: I18n.t(activity[:title_key]))
72+
end
5973
end
6074

6175
def chapters
6276
CHAPTERS
6377
end
6478

6579
def featured_sponsors
66-
FEATURED_SPONSORS
80+
FEATURED_SPONSORS.map do |sponsor|
81+
sponsor.merge(alt: I18n.t(sponsor[:alt_key]))
82+
end
6783
end
6884

6985
def previous_sponsors
70-
PREVIOUS_SPONSORS
86+
PREVIOUS_SPONSORS.map do |sponsor|
87+
sponsor.merge(alt: I18n.t(sponsor[:alt_key]))
88+
end
7189
end
7290

7391
def socials
74-
SOCIALS
92+
SOCIALS.map do |social|
93+
social.merge(alt: I18n.t(social[:alt_key]))
94+
end
7595
end
7696
end

app/views/chapters/index.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<% content_for(:title,"Chapters") %>
2-
<% content_for(:description," A showcase of the different ruby communities spread across the East African region.") %>
1+
<% content_for(:title, t('chapters.index.page_title')) %>
2+
<% content_for(:description, t('chapters.index.page_description')) %>
33
<div class="container pt-20 px-4 xl:px-56 mx-auto">
44
<h1 class="pt-16 pb-16 text-4xl text-red-600 font-bold text-5xl">
5-
Chapters
5+
<%= t('chapters.index.title') %>
66
</h1>
77

88
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2

app/views/devise/confirmations/new.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<%= image_tag 'sign_up_karate.png' %>
55
</figure>
66
<div class="card-body">
7-
<h2 class="card-title">Resend confirmation instructions</h2>
7+
<h2 class="card-title"><%= t('devise.views.confirmations.new.title') %></h2>
88

99
<%= simple_form_for(resource, as: resource_name,
1010
url: confirmation_path(resource_name)) do |f| %>
11-
<%= f.input :email, placeholder: 'Enter email address', label: 'Email',
11+
<%= f.input :email, placeholder: t('devise.views.confirmations.new.email_placeholder'), label: t('devise.views.confirmations.new.email_label'),
1212
input_html: { class: 'input-bordered w-full', autocomplete: 'email',
1313
autofocus: true,
1414
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) } %>
1515

1616
<div class="card-actions justify-end pt-8">
17-
<%= f.button :button, 'Resend instructions', class: 'btn btn-primary' %>
17+
<%= f.button :button, t('devise.views.confirmations.new.submit_button'), class: 'btn btn-primary' %>
1818
</div>
1919
<% end %>
2020

app/views/devise/passwords/edit.html.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
<%= image_tag 'sign_up_karate.png' %>
55
</figure>
66
<div class="card-body">
7-
<h2 class="card-title">Change your password</h2>
7+
<h2 class="card-title"><%= t('devise.views.passwords.edit.title') %></h2>
88

99
<%= simple_form_for(resource, as: resource_name,
1010
url: password_path(resource_name), html: { method: :put }) do |f| %>
1111
<%= f.hidden_field :reset_password_token %>
1212

13-
<%= f.input :password, placeholder: 'Enter new password', label: 'Password',
13+
<%= f.input :password, placeholder: t('devise.views.passwords.edit.password_placeholder'), label: t('devise.views.passwords.edit.password_label'),
1414
input_html: { class: 'input-bordered w-full', autofocus: true,
1515
autocomplete: "new-password" } %>
1616

17-
<%= f.input :password_confirmation, placeholder: 'Confirm new password',
18-
label: 'Confirm password', input_html: { class: 'input-bordered w-full',
17+
<%= f.input :password_confirmation, placeholder: t('devise.views.passwords.edit.password_confirmation_placeholder'),
18+
label: t('devise.views.passwords.edit.password_confirmation_label'), input_html: { class: 'input-bordered w-full',
1919
autocomplete: "new-password" } %>
2020

2121
<div class="card-actions justify-end pt-8">
22-
<%= f.button :button, 'Change my password', class: 'btn btn-primary' %>
22+
<%= f.button :button, t('devise.views.passwords.edit.submit_button'), class: 'btn btn-primary' %>
2323
</div>
2424
<% end %>
2525

app/views/devise/passwords/new.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<%= image_tag 'sign_up_karate.png' %>
55
</figure>
66
<div class="card-body">
7-
<h2 class="card-title">Forgot your password?</h2>
7+
<h2 class="card-title"><%= t('devise.views.passwords.new.title') %></h2>
88

99
<%= simple_form_for(resource, as: resource_name,
1010
url: password_path(resource_name)) do |f| %>
1111
<%#= f.invisible_captcha :nickname %>
12-
<%= f.input :email, placeholder: 'Enter email address', label: 'Email',
12+
<%= f.input :email, placeholder: t('devise.views.passwords.new.email_placeholder'), label: t('devise.views.passwords.new.email_label'),
1313
input_html: { class: 'input-bordered w-full', autocomplete: 'email',
1414
autofocus: true } %>
1515

1616
<div class="card-actions justify-end pt-8">
17-
<%= f.button :button, 'Send me instructions', class: 'btn btn-primary' %>
17+
<%= f.button :button, t('devise.views.passwords.new.submit_button'), class: 'btn btn-primary' %>
1818
</div>
1919
<% end %>
2020

app/views/devise/registrations/new.html.erb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@
44
<%= image_tag 'sign_up_karate.png' %>
55
</figure>
66
<div class="card-body">
7-
<h2 class="card-title">Create an account</h2>
7+
<h2 class="card-title"><%= t('devise.views.registrations.new.title') %></h2>
88

99
<%= simple_form_for(resource, as: resource_name,
1010
url: registration_path(resource_name),
1111
html: { data: { controller: "bot-detection", bot_detection_target: "form" } }) do |f| %>
1212

1313
<%#= f.invisible_captcha :nickname %>
1414

15-
<%= f.input :email, placeholder: 'Enter email address', label: 'Email',
15+
<%= f.input :email, placeholder: t('devise.views.registrations.new.email_placeholder'), label: t('devise.views.registrations.new.email_label'),
1616
input_html: { class: 'input-bordered w-full', autocomplete: 'email' } %>
1717

18-
<%= f.input :name, placeholder: 'Enter full name', label: 'Full name',
18+
<%= f.input :name, placeholder: t('devise.views.registrations.new.name_placeholder'), label: t('devise.views.registrations.new.name_label'),
1919
input_html: { class: 'input-bordered w-full', autocomplete: 'name' } %>
2020

21-
<%= f.input :phone_number, placeholder: 'Enter phone number', label: 'Phone number',
22-
hint: 'Start with a country e.g 254xxxxxxxxx. Use a WhatsApp number if possible',
21+
<%= f.input :phone_number, placeholder: t('devise.views.registrations.new.phone_number_placeholder'), label: t('devise.views.registrations.new.phone_number_label'),
22+
hint: t('devise.views.registrations.new.phone_number_hint'),
2323
input_html: { class: 'input-bordered w-full', autocomplete: 'phone_number' } %>
2424

2525
<div class="form-control email optional user_chapter">
26-
<label class="label"><span class="label-text">Chapter</span></label>
26+
<label class="label"><span class="label-text"><%= t('devise.views.registrations.new.chapter_label') %></span></label>
2727
<%= select_tag :chapter_id, options_from_collection_for_select(Chapter.all, 'id', 'name'),
2828
include_blank: false,
2929
class: "input input-bordered string email required input-bordered w-full" %>
3030
</div>
3131

32-
<%= f.input :github_username, placeholder: 'Enter Github username', label: 'Github username',
33-
hint: 'Must be a valid GitHub account. We will verify this username.',
32+
<%= f.input :github_username, placeholder: t('devise.views.registrations.new.github_username_placeholder'), label: t('devise.views.registrations.new.github_username_label'),
33+
hint: t('devise.views.registrations.new.github_username_hint'),
3434
input_html: { class: 'input-bordered w-full', autocomplete: 'github_username' } %>
3535

36-
<%= f.input :password, placeholder: 'Enter password', label: 'Password',
36+
<%= f.input :password, placeholder: t('devise.views.registrations.new.password_placeholder'), label: t('devise.views.registrations.new.password_label'),
3737
input_html: { class: 'input-bordered w-full' } %>
3838

39-
<%= f.input :password_confirmation, placeholder: 'Confirm Password',
40-
label: 'Confirm Password', input_html: { class: 'input-bordered w-full' } %>
39+
<%= f.input :password_confirmation, placeholder: t('devise.views.registrations.new.password_confirmation_placeholder'),
40+
label: t('devise.views.registrations.new.password_confirmation_label'), input_html: { class: 'input-bordered w-full' } %>
4141

4242

4343
<%= render "shared/cloudflare_turnstile" %>
4444

4545
<div class="card-actions justify-end pt-8">
46-
<%= f.button :button, 'Create Account', class: 'btn btn-primary
46+
<%= f.button :button, t('devise.views.registrations.new.submit_button'), class: 'btn btn-primary
4747
4848
disabled:cursor-not-allowed
4949
disabled:bg-gray-200

app/views/devise/sessions/new.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<%= image_tag 'sign_up_karate.png' %>
55
</figure>
66
<div class="card-body">
7-
<h2 class="card-title">Sign In</h2>
7+
<h2 class="card-title"><%= t('devise.views.sessions.new.title') %></h2>
88
<% if @turnstile_error %>
99
<div class="alert alert-error mb-4">
1010
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24">
@@ -16,10 +16,10 @@
1616

1717
<%= simple_form_for(resource, as: resource_name,
1818
url: session_path(resource_name), html: { id: 'new_user' }) do |f| %>
19-
<%= f.input :email, placeholder: 'Enter email address', label: 'Email',
19+
<%= f.input :email, placeholder: t('devise.views.sessions.new.email_placeholder'), label: t('devise.views.sessions.new.email_label'),
2020
input_html: { class: 'input-bordered w-full', autofocus: true, autocomplete: 'email' } %>
2121

22-
<%= f.input :password, placeholder: 'Enter password', label: 'Password',
22+
<%= f.input :password, placeholder: t('devise.views.sessions.new.password_placeholder'), label: t('devise.views.sessions.new.password_label'),
2323
input_html: { class: 'input-bordered w-full' } %>
2424

2525

@@ -28,7 +28,7 @@
2828

2929

3030
<div class="card-actions justify-end pt-8">
31-
<%= f.button :button, 'Sign In',
31+
<%= f.button :button, t('devise.views.sessions.new.submit_button'),
3232
class: 'btn btn-primary
3333
disabled:cursor-not-allowed
3434
disabled:bg-gray-200

0 commit comments

Comments
 (0)