From 85f7ca4058d5337af4e5f2c1a2ed1d4625ce113b Mon Sep 17 00:00:00 2001 From: Jim Stallings Date: Sat, 29 Aug 2015 18:39:38 -0400 Subject: [PATCH 1/2] GS-658 - internationalize drop down links and page titles --- app/views/crops/index.html.haml | 4 +- app/views/forums/index.html.haml | 2 +- app/views/harvests/index.html.haml | 2 +- app/views/layouts/_header.html.haml | 42 +++++++++---------- app/views/members/index.html.haml | 2 +- app/views/places/index.html.haml | 2 +- app/views/plantings/index.html.haml | 2 +- app/views/posts/index.html.haml | 2 +- app/views/seeds/index.html.haml | 2 +- app/views/shop/index.html.haml | 2 +- config/locales/en.yml | 65 +++++++++++++++++++++++++++++ 11 files changed, 96 insertions(+), 31 deletions(-) diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index d1be6fa49..9c50b029c 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -1,5 +1,5 @@ -- content_for :title, "Browse crops" -- content_for :subtitle, "#{@crops.size} total" +- content_for :title, t('.title') +- content_for :subtitle, t('.subtitle', crops_size: @crops.size) - if can? :wrangle, Crop = link_to 'Wrangle Crops', wrangle_crops_path, :class => 'btn btn-primary' diff --git a/app/views/forums/index.html.haml b/app/views/forums/index.html.haml index f838160a3..25649f937 100644 --- a/app/views/forums/index.html.haml +++ b/app/views/forums/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, "Forums" +- content_for :title, t('.title') - if can? :create, Forum %p diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index a6ef4d312..a99097d81 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, @owner ? "#{@owner}'s harvests" : @crop ? "Everyone's #{@crop.name} harvests" : "Everyone's harvests" +- content_for :title, @owner ? t('.title.owner_harvests', owner: @owner) : @crop ? t('.title.crop_harvests', crop: @crop.name) : t('.title.default') - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 30e549f3b..ddc9c6af2 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -23,48 +23,48 @@ Crops %b.caret %ul.dropdown-menu - %li= link_to "Browse Crops", crops_path - %li= link_to "Seeds", seeds_path - %li= link_to "Plantings", plantings_path - %li= link_to "Harvests", harvests_path + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path %li.dropdown< %a.dropdown-toggle{'data-toggle' => 'dropdown', :href => members_path} Community %b.caret %ul.dropdown-menu - %li= link_to "Community Map", places_path - %li= link_to "Browse Members", members_path - %li= link_to "Posts", posts_path - %li= link_to "Forums", forums_path - %li= link_to "Support Growstuff", shop_path + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path + %li= link_to t('.support_growstuff'), shop_path - if member_signed_in? %li.dropdown< %a.dropdown-toggle{'data-toggle' => 'dropdown', :href => root_path} - if current_member.notifications.unread_count > 0 - Your Stuff (#{current_member.notifications.unread_count}) + = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else #{current_member.login_name} %b.caret %ul.dropdown-menu - %li= link_to "Profile", member_path(current_member) - %li= link_to "Gardens", gardens_by_owner_path(:owner => current_member.slug) - %li= link_to "Plantings", plantings_by_owner_path(:owner => current_member.slug) - %li= link_to "Harvests", harvests_by_owner_path(:owner => current_member.slug) - %li= link_to "Seeds", seeds_by_owner_path(:owner => current_member.slug) - %li= link_to "Posts", posts_by_author_path(:author => current_member.slug) - %li= link_to "Account", orders_path + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(:owner => current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(:owner => current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(:owner => current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(:owner => current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(:author => current_member.slug) + %li= link_to t('.account'), orders_path %li - if current_member.notifications.unread_count > 0 - = link_to("Inbox (#{current_member.notifications.unread_count})", notifications_path) + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), notifications_path) - else - = link_to("Inbox", notifications_path) + = link_to(t('.inbox'), notifications_path) - if current_member.has_role?(:crop_wrangler) || current_member.has_role?(:admin) %li{:class => 'divider', :role => 'presentation'} - if current_member.has_role?(:crop_wrangler) - %li= link_to "Crop Wrangling", wrangle_crops_path + %li= link_to t('.crop_wrangling'), wrangle_crops_path - if current_member.has_role?(:admin) - %li= link_to "Admin", admin_path + %li= link_to t('.admin'), admin_path %li= link_to "Sign out", destroy_member_session_path, :method => :delete diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index 0fa659ede..705d69594 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -1,4 +1,4 @@ -= content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} members" += content_for :title, t(".title", site_name: "#{ENV['GROWSTUFF_SITE_NAME']}") = form_tag(members_path, :method => :get, :class => 'form-inline', :role => 'form') do .form-group diff --git a/app/views/places/index.html.haml b/app/views/places/index.html.haml index a81dd6ba8..fe3264375 100644 --- a/app/views/places/index.html.haml +++ b/app/views/places/index.html.haml @@ -1,4 +1,4 @@ --content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} Community Map" +-content_for :title, t(".title", site_name: "#{ENV['GROWSTUFF_SITE_NAME']}") = render partial: 'search_form' %div#placesmap diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 5563ffbfc..d048a0e89 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, @owner ? "#{@owner}'s plantings" : @crop ? "Everyone's #{@crop.name} plantings" : "Everyone's plantings" +- content_for :title, @owner ? t('.title.owner_plantings', owner: @owner) : @crop ? t('.title.crop_plantings', crop: @crop.name) : t('.title.default') - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 930dbdf84..4a5846f55 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, @author ? "#{@author}'s posts" : "Everyone's posts" +- content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default') %p - if can? :create, Post diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 800c48417..9bd5cde84 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -1,4 +1,4 @@ -- content_for :title, @owner ? "#{@owner}'s seeds" : @crop ? "Everyone's #{@crop.name} seeds" : "Everyone's seeds" +- content_for :title, @owner ? t('.title.owner_seeds', owner: @owner) : @crop ? t('.title.crop_seeds', crop: @crop.name) : t('.title.default') - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml index a31f71655..da7008d69 100644 --- a/app/views/shop/index.html.haml +++ b/app/views/shop/index.html.haml @@ -1,4 +1,4 @@ --content_for :title, 'Shop' +-content_for :title, t('.title') %p Growstuff relies on your support to build and run this open source diff --git a/config/locales/en.yml b/config/locales/en.yml index 643975551..1551c4eb6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,6 +17,71 @@ en: layouts: header: skip: "Skip navigation menu" + browse_crops: "Browse Crops" + seeds: "Seeds" + plantings: "Plantings" + harvests: "Harvests" + community_map: "Community Map" + browse_members: "Browse Members" + posts: "Posts" + forums: "Forums" + support_growstuff: "Support Growstuff" + profile: "Profile" + gardens: "Gardens" + account: "Account" + inbox_unread: "Inbox (%{unread_count})" + inbox: "Inbox" + crop_wrangling: "Crop Wrangling" + admin: "Admin" + your_stuff: "Your Stuff (%{unread_count})" + + crops: + index: + title: "Browse Crops" + subtitle: "%{crops_size} total" + + seeds: + index: + title: + default: "Everyone's seeds" + crop_seeds: "Everyone's %{crop} seeds" + owner_seeds: "%{owner} seeds" + + plantings: + index: + title: + default: "Everyone's plantings" + crop_plantings: "Everyone's %{crop} plantings" + owner_plantings: "%{owner} plantings" + + harvests: + index: + title: + default: "Everyone's harvests" + crop_harvests: "Everyone's %{crop} harvests" + owner_harvests: "%{owner} harvests" + + places: + index: + title: "%{site_name} Community Map" + + members: + index: + title: "%{site_name} members" + + posts: + index: + title: + default: "Everyone's posts" + author_posts: "%{author} posts" + + shop: + index: + title: "Shop" + + forums: + index: + title: "Forums" home: blurb: From b8b511e74781226412251783b00c3e28e0ee6461 Mon Sep 17 00:00:00 2001 From: Jim Stallings Date: Sun, 30 Aug 2015 11:02:47 -0400 Subject: [PATCH 2/2] GS-658 - use yaml anchor for duplicate values --- config/locales/en.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 1551c4eb6..8d77afdc8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -17,14 +17,14 @@ en: layouts: header: skip: "Skip navigation menu" - browse_crops: "Browse Crops" + browse_crops: &browse_crops "Browse Crops" seeds: "Seeds" plantings: "Plantings" harvests: "Harvests" community_map: "Community Map" browse_members: "Browse Members" posts: "Posts" - forums: "Forums" + forums: &forums "Forums" support_growstuff: "Support Growstuff" profile: "Profile" gardens: "Gardens" @@ -37,7 +37,7 @@ en: crops: index: - title: "Browse Crops" + title: *browse_crops subtitle: "%{crops_size} total" seeds: @@ -81,7 +81,7 @@ en: forums: index: - title: "Forums" + title: *forums home: blurb: