Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing translations (en); and enforce coverage. #3184

Open
wants to merge 33 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3802374
Add spec for detecting missed translations
CloCkWeRX Dec 9, 2022
c51dd50
Translations
CloCkWeRX Dec 9, 2022
e325d7a
Skip images. Later, may want to add js checking for any i18n usage there
CloCkWeRX Dec 9, 2022
eec7bac
Fix button translations
CloCkWeRX Dec 9, 2022
9250a17
Fix buttons
CloCkWeRX Dec 9, 2022
9f47081
Add missing translations, auto generated. May want to duplicate the c…
CloCkWeRX Dec 9, 2022
5370dc9
[CodeFactor] Apply fixes
code-factor Dec 9, 2022
974a101
Update en.yml
CloCkWeRX Dec 9, 2022
d1b25ef
Update config/locales/en.yml
CloCkWeRX Dec 9, 2022
6e36525
Update config/locales/en.yml
CloCkWeRX Dec 9, 2022
6719024
Update en.yml
CloCkWeRX Dec 9, 2022
a14cc80
Add rails-i18n
CloCkWeRX Dec 9, 2022
70726e7
Fix translations
CloCkWeRX Dec 9, 2022
03c65ad
Codefactor
CloCkWeRX Dec 9, 2022
54169fe
Adjust translates
CloCkWeRX Dec 10, 2022
8512a19
Remove unused keys
CloCkWeRX Dec 10, 2022
1e30aa7
Remove old keys
CloCkWeRX Dec 10, 2022
fa15889
Disable normalisation test for now
CloCkWeRX Dec 10, 2022
d0185c4
Remove dead translations
CloCkWeRX Dec 10, 2022
9265cad
Remove more unused translations
CloCkWeRX Dec 10, 2022
ef427a7
Remove more unused
CloCkWeRX Dec 10, 2022
a839d68
Remove more unused
CloCkWeRX Dec 10, 2022
7598f84
Remove unused
CloCkWeRX Dec 10, 2022
60a9d54
Remove unused
CloCkWeRX Dec 10, 2022
2853f72
Remove unused
CloCkWeRX Dec 10, 2022
051bfd5
Remove unused keys
CloCkWeRX Dec 10, 2022
497f14c
Remove unused keys
CloCkWeRX Dec 10, 2022
fbd8406
Remove model singular forms, we don't use them
CloCkWeRX Dec 10, 2022
32268e3
Merge branch 'dev' into issue/2745-translations
CloCkWeRX Dec 10, 2022
8934e30
Remove japanese local, as it is largely untranslated
CloCkWeRX Dec 10, 2022
ca92416
Update app/views/layouts/_menu.haml
CloCkWeRX Dec 10, 2022
177ca58
Drop pointless translations
CloCkWeRX Dec 10, 2022
e6563d0
Merge branch 'dev' into issue/2745-translations
CloCkWeRX Mar 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/admin/index.html.haml
Expand Up @@ -17,7 +17,7 @@
%li= link_to "Roles", admin_roles_path, class: 'nav-link'
%li= link_to "Forums", forums_path, class: 'nav-link'
%li= link_to "CMS", comfy_admin_cms_path, class: 'nav-link'
%li= link_to t('.garden_types'), garden_types_path, class: 'nav-link'
%li= link_to t('layouts.header.garden_types'), garden_types_path, class: 'nav-link'

.col-md-4
.card
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/roles/index.html.haml
Expand Up @@ -23,8 +23,8 @@
- if can? :edit, role
= link_to edit_admin_role_path(role), class: 'btn btn-default btn-xs' do
= edit_icon
= t('.edit')
= t('buttons.edit')
- if can?(:destroy, role) && ! role.members.any?
= link_to admin_role_path(role), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs text-danger' do
= delete_icon
= t('.delete')
= t('buttons.delete')
4 changes: 2 additions & 2 deletions app/views/crops/_alternate_names.html.haml
Expand Up @@ -10,11 +10,11 @@
- if can? :edit, an
= link_to edit_alternate_name_path(an), class: 'dropdown-item' do
= edit_icon
= t('.edit')
= t('buttons.edit')
- if can? :destroy, an
= link_to an, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item' do
= delete_icon
= t('.delete')
= t('buttons.delete')
- else
.badge= an.name

Expand Down
4 changes: 2 additions & 2 deletions app/views/crops/_scientific_names.html.haml
Expand Up @@ -10,11 +10,11 @@
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "planting-actions-button"}
= link_to edit_scientific_name_path(sn), class: 'dropdown-item' do
= edit_icon
= t('.edit')
= t('buttons.edit')
.dropdown-divider
= link_to sn, method: :delete, data: { confirm: 'Are you sure?' }, class: 'dropdown-item text-danger' do
= delete_icon
= t('.delete')
= t('buttons.delete')
- else
.badge= sn.name

Expand Down
2 changes: 1 addition & 1 deletion app/views/crops/_wrangle.html.haml
Expand Up @@ -8,7 +8,7 @@
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"}
= link_to edit_crop_path(crop), class: 'dropdown-item' do
= edit_icon
= t('.edit')
= t('buttons.edit')

= link_to crop_openfarm_path(crop), method: :post, class: 'dropdown-item' do
= icon 'far', 'update'
Expand Down
3 changes: 2 additions & 1 deletion config/i18n-tasks.yml
Expand Up @@ -47,7 +47,8 @@ search:

## Paths to search in, passed to File.find
paths:
- app/
- app/views/
- app/controllers/

## Root for resolving relative keys (default)
# relative_roots:
Expand Down
133 changes: 60 additions & 73 deletions config/locales/en.yml
@@ -1,35 +1,4 @@
---
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# The following keys must be escaped otherwise they will not be retrieved by
# the default I18n backend:
#
# true, false, on, off, yes, no
#
# Instead, surround them with single quotes.
#
# en:
# 'true': 'foo'
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.

en:
activerecord:
models:
Expand Down Expand Up @@ -80,27 +49,33 @@ en:
mark_as_finished: Mark as finished
mark_as_inactive: Mark as inactive
my_gardens: My Gardens
new_seeds: New saved seed
new_harvest: New harvest
new_planting: New planting
new_post: Write new post
new_harvest: New harvest
new_seeds: New saved seed
plant: Plant
plant_crop: Plant %{crop_name}
plant_something: Plant something
plant_something_here: Plant something here
record_harvest: Record Harvest
save_seeds: Save seeds
timeline: Timeline
write_blog_post: Write blog post
crops:
search: Search crops
index:
subtitle: "%{crops_size} total"
title: Browse Crops
requested:
link: You have %{number_crops} crops awaiting approval
subtitle: Pending approval
title: Requested crops
search: Search crops
date:
abbr_month_names: Abbr month names
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved
edit_crop: Edit crop
errors:
messages:
not_saved: Not saved
forms:
optional: "(Optional)"
forums:
Expand Down Expand Up @@ -131,9 +106,7 @@ en:
home:
blurb:
already_html: Or %{sign_in} if you already have an account
intro: >
%{site_name} is a community of food gardeners. %{site_name}'s open source and open data platform
can predict when your plantings will be ready to harvest. The more you tell it, the better the predictions.
intro: "%{site_name} is a community of food gardeners. %{site_name}'s open source and open data platform can predict when your plantings will be ready to harvest. The more you tell it, the better the predictions.\n"
perks: Join now for your free garden journal, harvest predictions, forums, and more.
sign_in_linktext: sign in
sign_up: Sign up
Expand All @@ -146,6 +119,9 @@ en:
discussion: Discussion
forums: Forums
view_all: View all posts
harvests:
recently_harvested: Recently Harvested
view_all: View all harvests
index:
add_seeds: Add seeds
edit_profile: Edit profile
Expand All @@ -154,32 +130,24 @@ en:
post: Post
recently_added: Recently Added
welcome: Welcome to %{site_name}, %{member_name}
harvests:
view_all: View all harvests
members:
title: Some of our members
view_all: View all members
open:
ad_free_linktext: ad-free
api_docs_linktext: API documentation
creative_commons_linktext: Creative Commons license
get_involved_body_html: >
We believe in collaboration, and work closely with our members and the wider food-growing community.
Our team includes volunteers from all walks of life and all skill levels. To get involved,
visit %{talk_link} or find more information on the %{wiki_link}.
get_involved_body_html: 'We believe in collaboration, and work closely with our members and the wider food-growing community. Our team includes volunteers from all walks of life and all skill levels. To get involved, visit %{talk_link} or find more information on the %{wiki_link}.
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved

'
get_involved_title: Get Involved
github_linktext: Github
open_data_body_html: >
We're building a database of crops, planting advice, seed sources, and other information that anyone
can use for free, under a %{creative_commons_link}. You can use this data for research, to build apps,
or for any purpose at all. Read more about our %{wiki_link} and %{api_docs_link}.
open_data_body_html: 'We''re building a database of crops, planting advice, seed sources, and other information that anyone can use for free, under a %{creative_commons_link}. You can use this data for research, to build apps, or for any purpose at all. Read more about our %{wiki_link} and %{api_docs_link}.
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved

'
open_data_title: Open Data and APIs
open_source_body_html: >
%{site_name} is open source software, which means that we share this website's code for free with our
community and the world. We believe that openness, sustainability, and social good go hand in hand.
You can read more about %{why} or check out our code on %{github}.
open_source_body_html: "%{site_name} is open source software, which means that we share this website's code for free with our community and the world. We believe that openness, sustainability, and social good go hand in hand. You can read more about %{why} or check out our code on %{github}.\n"
open_source_title: Open Source

support_body_html: Growstuff is independent, %{ad_free} and we have no outside investment. You can support our work by %{buy_account}.
support_title: Support Growstuff
talk_linktext: Growstuff Talk
Expand All @@ -205,47 +173,65 @@ en:
number_gardens_linktext: "%{count} gardens"
number_plantings_linktext: "%{count} times"
label:
days_until_harvest: "%{number} days"
weeks_until_harvest: "%{number} weeks until harvest"
data: 'The data on this page is available in the following formats:'
days_until_finished: "%{number} days"
weeks_until_finished: "%{number} weeks"
days_until_harvest: "%{number} days"
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved
harvesting_now: harvesting now
data: 'The data on this page is available in the following formats:'
weeks_until_finished: "%{number} weeks"
weeks_until_harvest: "%{number} weeks until harvest"
layouts:
application:
skip: Skip
header:
account: Account
admin: Admin
browse_crops: Browse Crops
browse_members: Browse Members
community: Community
community_map: Community Map
garden_type: Garden Type
garden_types: Garden Types
crop_wrangling: Crop Wrangling
crops: Crops
current_memberlogin_name: "%{current_memberlogin_name}"
forums: Forums
garden_type: Garden Type
garden_types: Garden Types
gardens: Gardens
harvest: Harvest
harvests: Harvests
record: Record
inbox: Inbox
inbox_unread: Inbox (%{unread_count})
plantings: Plantings
posts: Posts
profile: Profile
record: Record
seeds: Seeds
skip: Skip navigation menu
support_growstuff: Support Growstuff
toggle_navigation: Toggle Navigation
your_stuff: Your Stuff
menu:
admin: Admin
browse_crops: Browse crops
browse_members: Browse members
community: Community
community_map: Community map
crop_wrangling: Crop wrangling
crops: Crops
forums: Forums
gardens: Gardens
harvest: Harvest
harvests: Harvests
inbox: Inbox
plantings: Plantings
posts: Posts
profile: Profile
record: Record
seeds: Seeds
sign_in: Sign in
sign_out: Sign out
sign_up: Sign up
links:
my_gardens: My gardens

members:
edit_profile: Edit profile
index:
Expand Down Expand Up @@ -284,34 +270,34 @@ en:
late_finishing: late finishing
sharedbuttonsfinish_planting: shared/buttons/finish_planting
super_late: super late
plant_something: Plant something
form:
finish_helper: >
A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise
no longer growing in your garden.
finish_helper: 'A planting is finished when you''ve harvested all of the crop, or it dies, or it''s otherwise no longer growing in your garden.

'
index:
title:
crop_plantings: Everyone's %{crop} plantings
default: Everyone's plantings
owner_plantings: "%{owner}'s plantings"
view_owners_profile: View %{owner}'s profile >>
string: "%{crop} planting in %{garden} by %{owner}"
plant_something: Plant something
progress:
progress_0_not_planted_yet: 'Progress: 0% - not planted yet'
string: "%{crop} planting in %{garden} by %{owner}"
posts:
write_blog_post: Write blog post
index:
title:
author_posts: "%{author} posts"
default: Everyone's posts
write_blog_post: Write blog post
seeds:
form:
trade_help: >
Are you interested in trading or swapping seeds with other %{site_name} members? If you list
your seeds as available for trade, other members can contact you to request seeds. You can
list any conditions or other information in the description, above.
finish_helper: >
Seeds are finished when you've planted them all, or you've traded them all away.
finish_helper: 'Seeds are finished when you''ve planted them all, or you''ve traded them all away.

'
trade_help: 'Are you interested in trading or swapping seeds with other %{site_name} members? If you list your seeds as available for trade, other members can contact you to request seeds. You can list any conditions or other information in the description, above.

'
index:
title:
crop_seeds: Everyone's %{crop} seeds
Expand All @@ -322,12 +308,13 @@ en:
unauthorized:
create:
all: Please sign in or sign up to create a %{subject}.
garden_type: Not authorized. Only admins can create garden types.
notification: Please sign in to send a message.
planting: Please sign in or sign up to plant something.
post: Please sign in or sign up to post.
seed: Please sign in or sign up to add seeds.
garden_type: Not authorized. Only admins can create garden types.
manage:
all: Not authorized to %{action} %{subject}.
read:
notification: You must be signed in to view notifications.
view: View
35 changes: 35 additions & 0 deletions spec/views/i18n_spec.rb
@@ -0,0 +1,35 @@
# frozen_string_literal: true

require 'rails_helper'
require 'i18n/tasks'

RSpec.describe I18n do
let(:i18n) { I18n::Tasks::BaseTask.new }
let(:missing_keys) { i18n.missing_keys }
let(:unused_keys) { i18n.unused_keys }
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }

it 'does not have missing keys' do
expect(missing_keys).to be_empty,
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
end

it 'does not have unused keys' do
expect(unused_keys).to be_empty,
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
end

it 'files are normalized' do
non_normalized = i18n.non_normalized_paths
error_message = "The following files need to be normalized:\n" \
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
"Please run `i18n-tasks normalize' to fix"
expect(non_normalized).to be_empty, error_message
end

it 'does not have inconsistent interpolations' do
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
"Run `i18n-tasks check-consistent-interpolations' to show them"
expect(inconsistent_interpolations).to be_empty, error_message
end
end