From: Shaun McDonald Date: Wed, 27 May 2009 17:19:59 +0000 (+0000) Subject: Diary entries pretty much i18n'd. Additional test that checks there are no missing... X-Git-Tag: live~7378^2~66 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b377927a6428ca30a67b2daeae48ae9bac1f851d Diary entries pretty much i18n'd. Additional test that checks there are no missing translation strings, need more like it. --- diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index 9fad57c02..9bbadb29d 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -115,7 +115,11 @@ class DiaryEntryController < ApplicationController if user @entry = DiaryEntry.find(:first, :conditions => ['user_id = ? AND id = ?', user.id, params[:id]]) - @title = "Users' diaries | #{params[:display_name]}" + if @entry + @title = "Users' diaries | #{params[:display_name]}" + else + render :action => 'no_such_entry', :status => :not_found + end else @not_found_user = params[:display_name] diff --git a/app/views/diary_entry/_diary_comment.rhtml b/app/views/diary_entry/_diary_comment.rhtml index 2aca51f54..45cce0b25 100644 --- a/app/views/diary_entry/_diary_comment.rhtml +++ b/app/views/diary_entry/_diary_comment.rhtml @@ -1,3 +1,3 @@ -

Comment from <%= link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name %> at <%= diary_comment.created_at %>

+

<%= t('diary_entry.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at)) %>

<%= htmlize(diary_comment.body) %>
diff --git a/app/views/diary_entry/edit.rhtml b/app/views/diary_entry/edit.rhtml index 615d4b69b..a08f7182e 100644 --- a/app/views/diary_entry/edit.rhtml +++ b/app/views/diary_entry/edit.rhtml @@ -5,30 +5,30 @@ <% form_for :diary_entry do |f| %> - + - + - + - + @@ -76,7 +76,7 @@ removeMarkerFromMap(marker); } - marker = addMarkerToMap(lonlat, null, "Diary entry location"); + marker = addMarkerToMap(lonlat, null, "<%= t 'diary_entry.edit.marker_text' -%>"); } function openMap() { diff --git a/app/views/diary_entry/no_such_entry.rhtml b/app/views/diary_entry/no_such_entry.rhtml index 1ebcf269c..eef0e47d2 100644 --- a/app/views/diary_entry/no_such_entry.rhtml +++ b/app/views/diary_entry/no_such_entry.rhtml @@ -1,2 +1,2 @@ -

No entry with the id: <%= h(params[:id]) %>

-

Sorry, there is no diary entry or comment with the id <%=h params[:id] -%>, or no id was given. Please check your spelling, or maybe the link you clicked is wrong.

+

<%= t 'diary_entry.no_such_entry.heading', :id => h(params[:id]) %>

+

<%= t 'diary_entry.no_such_entry.body', :id => h(params[:id]) %>

diff --git a/app/views/diary_entry/no_such_user.rhtml b/app/views/diary_entry/no_such_user.rhtml index 7820b4847..02f6a4df2 100644 --- a/app/views/diary_entry/no_such_user.rhtml +++ b/app/views/diary_entry/no_such_user.rhtml @@ -1,2 +1,2 @@

<%= h(@not_found_user) %>

-

Sorry, there is no user with the name <%= @not_found_user -%>. Please check your spelling, or maybe the link you clicked is wrong.

+

<%= t 'diary_entry.no_such_user.body', :user => @not_found_user %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index d174ba087..15b25c4d6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -11,6 +11,21 @@ en: recent_entries: "Recent diary entries: " older_entries: Older Entries newer_entries: Newer Entries + edit: + subject: "Subject:" + body: "Body:" + language: "Language:" + location: "Location:" + latitude: "Latitude:" + longitude: "Longitude:" + use_map_link: "use map" + save_button: "Save" + marker_text: Diary entry location + no_such_entry: + heading: "No entry with the id: {{id}}" + body: "Sorry, there is no diary entry or comment with the id {{id}}. Please check your spelling, or maybe the link you clicked is wrong." + no_such_user: + body: "Sorry, there is no user with the name {{user}}. Please check your spelling, or maybe the link you clicked is wrong." posted_by: "Posted by {{link_user}} at {{created}} in {{language}}" comment_link: Comment on this entry reply_link: Reply to this entry @@ -18,3 +33,4 @@ en: one: 1 comment other: "{{count}} comments" edit_link: Edit this entry + comment_from: "Comment from {{link_user}} at {{comment_created_at}}" diff --git a/test/functional/diary_entry_controller_test.rb b/test/functional/diary_entry_controller_test.rb index 3bbf8ae0a..41db4436f 100644 --- a/test/functional/diary_entry_controller_test.rb +++ b/test/functional/diary_entry_controller_test.rb @@ -145,6 +145,16 @@ class DiaryEntryControllerTest < ActionController::TestCase end + def test_edit_diary_entry_i18n + I18n.available_locales.each do |locale| + set_locale locale + + get(:edit, {:id => diary_entries(:normal_user_entry_1).id}, {'user' => users(:normal_user).id}) + assert_response :success + assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry" + end + end + def test_create_diary_entry #post :new end @@ -162,11 +172,13 @@ class DiaryEntryControllerTest < ActionController::TestCase get :list assert_response :success, "Should be able to list the diary entries in #{locale}" assert_template 'list', "Should use the list template in #{locale}" + assert_select "span[class=translation_missing]", false, "Missing translation in list of diary entries" # Now try to find a specific user's diary entry get :list, {:display_name => users(:normal_user).display_name} assert_response :success, "Should be able to list the diary entries for a user in #{locale}" assert_template 'list', "Should use the list template for a user in #{locale}" + assert_select "span[class=translation_missing]", false, "Missing translation in list of diary entries for user" end end
Subject:<%= t 'diary_entry.edit.subject' -%> <%= f.text_field :title, :size => 60 %>
Body:<%= t 'diary_entry.edit.body' -%> <%= f.text_area :body, :cols => 80 %>
Language:<%= t 'diary_entry.edit.language' -%> <%= f.collection_select :language, Language.find(:all), :code, :name %>
Location:<%= t 'diary_entry.edit.location' -%> - Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %> - use map + <%= t 'diary_entry.edit.latitude' -%> <%= f.text_field :latitude, :size => 20, :id => "latitude" %> <%= t 'diary_entry.edit.longitude' -%> <%= f.text_field :longitude, :size => 20, :id => "longitude" %> + <%= t 'diary_entry.edit.use_map_link' -%>

- <%= submit_tag 'Save' %> + <%= submit_tag t 'diary_entry.edit.save_button' %> <%# TODO: button should say 'publish' or 'save changes' depending on new/edit state %>