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]
-<h4 id="comment<%= diary_comment.id %>">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 %></h4>
+<h4 id="comment<%= diary_comment.id %>"><%= 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)) %></h4>
<%= htmlize(diary_comment.body) %>
<hr />
<% form_for :diary_entry do |f| %>
<table>
<tr valign="top">
- <td class="fieldName">Subject:</td>
+ <td class="fieldName"><%= t 'diary_entry.edit.subject' -%></td>
<td><%= f.text_field :title, :size => 60 %></td>
</tr>
<tr valign="top">
- <td class="fieldName">Body:</td>
+ <td class="fieldName"><%= t 'diary_entry.edit.body' -%></td>
<td><%= f.text_area :body, :cols => 80 %></td>
</tr>
<tr valign="top">
- <td class="fieldName">Language:</td>
+ <td class="fieldName"><%= t 'diary_entry.edit.language' -%></td>
<td><%= f.collection_select :language, Language.find(:all), :code, :name %></td>
</tr>
<tr valign="top">
- <td class="fieldName">Location:</td>
+ <td class="fieldName"><%= t 'diary_entry.edit.location' -%></td>
<td>
<div id="map" style="border: 1px solid black; position: relative; width : 90%; height : 400px; display: none;"></div>
- <span class="location">Latitude: <%= f.text_field :latitude, :size => 20, :id => "latitude" %> Longitude: <%= f.text_field :longitude, :size => 20, :id => "longitude" %></span>
- <a href="javascript:openMap()" id="usemap">use map</a>
+ <span class="location"><%= 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" %></span>
+ <a href="javascript:openMap()" id="usemap"><%= t 'diary_entry.edit.use_map_link' -%></a>
<br/><br/>
</td>
</tr>
<tr>
<td></td>
<td>
- <%= submit_tag 'Save' %>
+ <%= submit_tag t 'diary_entry.edit.save_button' %>
<%# TODO: button should say 'publish' or 'save changes' depending on new/edit state %>
</td>
</tr>
removeMarkerFromMap(marker);
}
- marker = addMarkerToMap(lonlat, null, "Diary entry location");
+ marker = addMarkerToMap(lonlat, null, "<%= t 'diary_entry.edit.marker_text' -%>");
}
function openMap() {
-<h2>No entry with the id: <%= h(params[:id]) %></h2>
-<p>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.</p>
+<h2><%= t 'diary_entry.no_such_entry.heading', :id => h(params[:id]) %></h2>
+<p><%= t 'diary_entry.no_such_entry.body', :id => h(params[:id]) %></p>
<h2><%= h(@not_found_user) %></h2>
-<p>Sorry, there is no user with the name <%= @not_found_user -%>. Please check your spelling, or maybe the link you clicked is wrong.</p>
+<p><%= t 'diary_entry.no_such_user.body', :user => @not_found_user %></p>
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
one: 1 comment
other: "{{count}} comments"
edit_link: Edit this entry
+ comment_from: "Comment from {{link_user}} at {{comment_created_at}}"
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
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