added translations to templates; mock out the locale file in jasmine

This commit is contained in:
danielgrippi 2012-01-04 14:50:46 -08:00 committed by Dennis Collinson
parent a92401f157
commit 933299e31c
15 changed files with 138 additions and 58 deletions

View file

@ -1,7 +1,7 @@
<div class="right controls"> <div class="right controls">
<!-- need access to post --> <!-- need access to post -->
<% if(author.id === current_user.id) { %> <% if(author.id === current_user.id) { %>
<a href="#" class="delete comment_delete" title="Delete"> <a href="#" class="delete comment_delete" title="<%= Diaspora.I18n.t('delete') %>">
<img alt="Deletelabel" src="/images/deletelabel.png" /> <img alt="Deletelabel" src="/images/deletelabel.png" />
<a/> <a/>
<% } %> <% } %>

View file

@ -2,7 +2,7 @@
<ul class="show_comments <%= comments_count <= 3 ? 'hidden' : '' %>"> <ul class="show_comments <%= comments_count <= 3 ? 'hidden' : '' %>">
<li> <li>
<a href="/posts/<%= id %>/comments" class="toggle_post_comments"> <a href="/posts/<%= id %>/comments" class="toggle_post_comments">
Show <%= comments_count - 3 %> more comments <%= Diaspora.I18n.t('stream.more_comments', {count : comments_count - 3}) %>
</a> </a>
</li> </li>
</ul> </ul>
@ -18,11 +18,11 @@
</a> </a>
<p> <p>
<label for="comment_text_on_<%= id %>">Comment</label> <label for="comment_text_on_<%= id %>"><%= Diaspora.I18n.t('stream.comment') %></label>
<textarea class="comment_box" id="comment_text_on_<%= id %>" name="text" rows="2" /> <textarea class="comment_box" id="comment_text_on_<%= id %>" name="text" rows="2" />
</p> </p>
<div class="submit_button"> <div class="submit_button">
<input class="button creation" id="comment_submit_<%= id %>" name="commit" type="submit" value="Comment" /> <input class="button creation" id="comment_submit_<%= id %>" name="commit" type="submit" value="<%= Diaspora.I18n.t('stream.comment') %>" />
</div> </div>
</form> </form>
</div> </div>

View file

@ -1,21 +1,21 @@
<span class="post_scope"> <span class="post_scope">
<%= public ? "Public" : "Limited" %> <%= public ? Diaspora.I18n.t("stream.public") : Diaspora.I18n.t("stream.limited") %>
</span> </span>
<a href="#" class="like_action" rel='nofollow'> <a href="#" class="like_action" rel='nofollow'>
<%= user_like ? "Unlike" : "Like" %> <%= user_like ? Diaspora.I18n.t("stream.unlike") : Diaspora.I18n.t("stream.like") %>
</a> </a>
· ·
<% if(public && author.id != current_user.id && (post_type == "Reshare" ? root : true)) { %> <% if(public && author.id != current_user.id && (post_type == "Reshare" ? root : true)) { %>
<a href="#" class="reshare_action" rel='nofollow'> <a href="#" class="reshare_action" rel='nofollow'>
Reshare <%= Diaspora.I18n.t("stream.reshare") %>
</a> </a>
· ·
<% } %> <% } %>
<a href="#" class="focus_comment_textarea" rel="nofollow"> <a href="#" class="focus_comment_textarea" rel="nofollow">
Comment <%= Diaspora.I18n.t("stream.comment") %>
</a> </a>

View file

@ -1,4 +1,3 @@
<header>
<div class="container" style="position:relative;"> <div class="container" style="position:relative;">
<a href="/stream"> <a href="/stream">
@ -7,47 +6,59 @@
<div id="global_search"> <div id="global_search">
<form accept-charset="UTF-8" action="/people" class="search_form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div> <form accept-charset="UTF-8" action="/people" class="search_form" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"></div>
<input id="q" name="q" placeholder="Find people or #tags" results="5" type="search" autocomplete="off" class="ac_input"> <input id="q" name="q" placeholder="<%= Diaspora.I18n.t('header.search') %>" results="5" type="search" autocomplete="off" class="ac_input">
</form> </form>
</div> </div>
<div id="nav_badges"> <div id="nav_badges">
<div class="badge" id="home_badge"> <div class="badge" id="home_badge">
<a href="/stream" title="Home"><img alt="Home" src="/images/icons/home_grey.png"> <a href="/stream" title="<%= Diaspora.I18n.t('header.home') %>"><img alt="Home" src="/images/icons/home_grey.png">
</a> </a>
</div> </div>
<div class="badge" id="notification_badge"> <div class="badge" id="notification_badge">
<a href="/notifications" title="No new notifications"> <a href="/notifications" title="<%= Diaspora.I18n.t('header.notifications') %>">
<img alt="No new notifications" id="notification-flag" src="/images/icons/notifications_grey.png"> <img alt="<%= Diaspora.I18n.t('header.notifications') %>" id="notification-flag" src="/images/icons/notifications_grey.png">
<div class="badge_count hidden"> <div class="badge_count hidden">
0 0
</div> </div>
</a> </a>
</div> </div>
<div class="badge" id="message_inbox_badge"> <div class="badge" id="message_inbox_badge">
<a href="/conversations" title="No new messages"><img alt="No new messages" src="/images/icons/mail_grey.png"> <a href="/conversations" title="<%= Diaspora.I18n.t('header.messages') %>">
<img alt="<%= Diaspora.I18n.t('header.messages') %>" src="/images/icons/mail_grey.png">
<div class="badge_count hidden"> <div class="badge_count hidden">
0 0
</div> </div>
</a> </a>
</div> </div>
</div> </div>
<div id="notification_dropdown"> <div id="notification_dropdown">
<div class="header"> <div class="header">
<div class="right"> <div class="right">
<a href="/notifications/read_all">Mark All as Read</a> <a href="/notifications/read_all">
<%= Diaspora.I18n.t("header.mark_all_as_read") %>
</a>
| |
<a href="/notifications" id="view_all_notifications">View all</a> <a href="/notifications" id="view_all_notifications">
<%= Diaspora.I18n.t("header.view_all") %>
</a>
</div> </div>
<h4> <h4>
Recent notifications <%= Diaspora.I18n.t("header.recent_notifications") %>
</h4> </h4>
</div> </div>
<div class="notifications"> <div class="notifications">
<div class="ajax_loader"> <div class="ajax_loader">
<img alt="Ajax-loader" src="/images/ajax-loader.gif"> <img alt="Ajax-loader" src="/images/ajax-loader.gif">
</div> </div>
</div> </div>
</div> </div>
<div id="hovercard_container"> <div id="hovercard_container">
<div id="hovercard"> <div id="hovercard">
<img class="avatar"> <img class="avatar">
@ -63,6 +74,7 @@
</div> </div>
</div> </div>
</div> </div>
<ul class="dropdown" id="user_menu"> <ul class="dropdown" id="user_menu">
<li> <li>
<div class="right"> <div class="right">
@ -71,11 +83,12 @@
<img alt="<%= current_user.name %>" class="avatar" data-person_id="<%= current_user.id %>" src="<%= current_user.avatar.small %>" title="<%= current_user.name %>" /> <img alt="<%= current_user.name %>" class="avatar" data-person_id="<%= current_user.id %>" src="<%= current_user.avatar.small %>" title="<%= current_user.name %>" />
<a href="#"><%= current_user.name %></a> <a href="#"><%= current_user.name %></a>
</li> </li>
<li><a href="/people/<%= current_user.id %>">Profile</a></li> <li><a href="/people/<%= current_user.id %>"><%= Diaspora.I18n.t("header.profile") %></a></li>
<li><a href="/contacts">Contacts</a></li> <li><a href="/contacts"><%= Diaspora.I18n.t("header.contacts") %></a></li>
<li><a href="/user/edit">Settings</a></li> <li><a href="/user/edit"><%= Diaspora.I18n.t("header.settings") %></a></li>
<li><a href="/users/sign_out">Log out</a></li> <li><a href="/users/sign_out"><%= Diaspora.I18n.t("header.log_out") %></a></li>
</ul> </ul>
<div id="lightbox"> <div id="lightbox">
<div id="lightbox-content"> <div id="lightbox-content">
<a href="#" id="lightbox-close-link">[x] close</a> <a href="#" id="lightbox-close-link">[x] close</a>
@ -84,5 +97,5 @@
</div> </div>
</div> </div>
<div id="lightbox-backdrop"></div> <div id="lightbox-backdrop"></div>
</div> </div>
</header>

View file

@ -1,6 +1,6 @@
<% if(likes_count > 0) { %> <% if(likes_count > 0) { %>
<img alt="Heart" src="/images/icons/heart.png" /> <img alt="Heart" src="/images/icons/heart.png" />
<a href="#" class="expand_likes"> <a href="#" class="expand_likes">
<%= likes_count %> Like <%= Diaspora.I18n.t('stream.likes', {count: likes_count}) %>
</a> </a>
<% } %> <% } %>

View file

@ -22,7 +22,7 @@
<% if(root.reshares_count) { %> <% if(root.reshares_count) { %>
- -
<%= root.reshares_count %> reshares <%= Diaspora.I18n.t("stream.reshares", {count : root.reshares_count}) %>
<% } %> <% } %>
</div> </div>
@ -50,7 +50,7 @@
<% } else { %> <% } else { %>
<p> <p>
Original post deleted by author. <%= Diaspora.I18n.t('stream.original_post_deleted') %>
</p> </p>
<% } %> <% } %>
</div> </div>

View file

@ -1,8 +1,8 @@
<div class="right controls"> <div class="right controls">
<% if(author.id != current_user.id) { %> <% if(author.id != current_user.id) { %>
<img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title= "Ignore" /> <img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title= "<%= Diaspora.I18n.t('ignore') %>" />
<% } else { %> <% } else { %>
<img src="/images/deletelabel.png" class="delete control_icon remove_post" title="Delete" /> <img src="/images/deletelabel.png" class="delete control_icon remove_post" title="<%= Diaspora.I18n.t('delete') %>" />
<% } %> <% } %>
</div> </div>
@ -29,17 +29,17 @@
<% if(reshares_count) { %> <% if(reshares_count) { %>
- -
<%= reshares_count %> reshares <%= Diaspora.I18n.t("stream.reshares", {count : reshares_count}) %>
<% } %> <% } %>
</span> </span>
</div> </div>
<% if(text !== null && text.match(/#nsfw/)) { %> <% if(text !== null && text.match(/#nsfw/i)) { %>
<div class="shield_wrapper"> <div class="shield_wrapper">
<div class="shield"> <div class="shield">
This post has been flagged as NSFW by its author. <%= Diaspora.I18n.t('stream.nsfw') %>
<a href="#"> <a href="#">
show <%= Diaspora.I18n.t('stream.show') %>
</a> </a>
</div> </div>
<% } %> <% } %>

View file

@ -6,6 +6,8 @@
en: en:
javascripts: javascripts:
confirm_dialog: "Are you sure?" confirm_dialog: "Are you sure?"
delete: "Delete"
ignore: "Ignore"
timeago: timeago:
prefixAgo: "" prefixAgo: ""
prefixFromNow: "" prefixFromNow: ""
@ -32,8 +34,6 @@ en:
public: "Public - your post will be visible to everyone and found by search engines" public: "Public - your post will be visible to everyone and found by search engines"
infinite_scroll: infinite_scroll:
no_more: "No more posts." no_more: "No more posts."
web_sockets:
disconnected: "The websocket is closed; posts will no longer be streamed live."
aspect_dropdown: aspect_dropdown:
add_to_aspect: "Add contact" add_to_aspect: "Add contact"
select_aspects: "Select aspects" select_aspects: "Select aspects"
@ -44,7 +44,6 @@ en:
toggle: toggle:
zero: "Select aspects" zero: "Select aspects"
one: "In <%= count %> aspect" one: "In <%= count %> aspect"
two: "In <%= count %> aspects"
few: "In <%= count %> aspects" few: "In <%= count %> aspects"
many: "In <%= count %> aspects" many: "In <%= count %> aspects"
other: "In <%= count %> aspects" other: "In <%= count %> aspects"
@ -69,3 +68,52 @@ en:
looking_good: "OMG, you look awesome!" looking_good: "OMG, you look awesome!"
tags: tags:
wasnt_that_interesting: "OK, I suppose #<%= tagName %> wasn't all that interesting..." wasnt_that_interesting: "OK, I suppose #<%= tagName %> wasn't all that interesting..."
stream:
public: "Public"
limited: "Limited"
like: "Like"
unlike: "Unlike"
reshare: "Reshare"
comment: "Comment"
original_post_deleted: "Original post deleted by author."
nsfw: "This post has been flagged NSFW by its author."
show: "Show"
likes:
zero: "<%= count %> Likes"
one: "<%= count %> Like"
few: "<%= count %> Likes"
many: "<%= count %> Likes"
other: "<%= count %> Likes"
reshares:
zero: "<%= count %> Reshares"
one: "<%= count %> Reshare"
few: "<%= count %> Reshares"
many: "<%= count %> Reshares"
other: "<%= count %> Reshares"
more_comments:
zero: "Show <%= count %> more comments"
one: "Show <%= count %> more comment"
few: "Show <%= count %> more comments"
many: "Show <%= count %> more comments"
other: "Show <%= count %> more comments"
header:
home: "Home"
profile: "Profile"
contacts: "Contacts"
settings: "Settings"
log_out: "Log out"
notifications: "Notifications"
messages: "Messages"
search: "Find people or #tags"
recent_notifications: "Recent Notifications"
mark_all_as_read: "Mark all as read"
view_all: "View all"

View file

@ -14,7 +14,7 @@ Feature: Notifications
And I add the person to my "Besties" aspect And I add the person to my "Besties" aspect
And I go to the destroy user session page And I go to the destroy user session page
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I follow "notification" in the header And I follow "Notifications" in the header
And I wait for the ajax to finish And I wait for the ajax to finish
Then the notification dropdown should be visible Then the notification dropdown should be visible
Then I should see "started sharing with you" Then I should see "started sharing with you"
@ -32,10 +32,10 @@ Feature: Notifications
And I wait for the ajax to finish And I wait for the ajax to finish
And I go to the destroy user session page And I go to the destroy user session page
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I follow "notification" in the header And I follow "Notifications" in the header
And I wait for the ajax to finish #And I wait for the ajax to finish
Then the notification dropdown should be visible Then the notification dropdown should be visible
And I wait for the ajax to finish #And I wait for the ajax to finish
Then I should see "reshared your post" Then I should see "reshared your post"
And I should have 1 email delivery And I should have 1 email delivery
@ -49,7 +49,7 @@ Feature: Notifications
And I wait for the ajax to finish And I wait for the ajax to finish
And I go to the destroy user session page And I go to the destroy user session page
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I follow "notification" in the header And I follow "Notifications" in the header
And I wait for the ajax to finish And I wait for the ajax to finish
Then the notification dropdown should be visible Then the notification dropdown should be visible
And I wait for the ajax to finish And I wait for the ajax to finish
@ -67,7 +67,7 @@ Feature: Notifications
And I wait for the ajax to finish And I wait for the ajax to finish
And I go to the destroy user session page And I go to the destroy user session page
When I sign in as "alice@alice.alice" When I sign in as "alice@alice.alice"
And I follow "notification" in the header And I follow "Notifications" in the header
And I wait for the ajax to finish And I wait for the ajax to finish
Then the notification dropdown should be visible Then the notification dropdown should be visible
And I wait for the ajax to finish And I wait for the ajax to finish
@ -78,7 +78,7 @@ Feature: Notifications
Given a user with email "bob@bob.bob" is connected with "alice@alice.alice" Given a user with email "bob@bob.bob" is connected with "alice@alice.alice"
And Alice has a post mentioning Bob And Alice has a post mentioning Bob
When I sign in as "bob@bob.bob" When I sign in as "bob@bob.bob"
And I follow "notification" in the header And I follow "Notifications" in the header
And I wait for the ajax to finish And I wait for the ajax to finish
Then the notification dropdown should be visible Then the notification dropdown should be visible
And I wait for the ajax to finish And I wait for the ajax to finish

View file

@ -2,6 +2,8 @@ app.views.Header = app.views.Base.extend({
template_name : "#header-template", template_name : "#header-template",
tagName : "header",
events : { events : {
"click ul.dropdown li:first-child" : "toggleDropdown" "click ul.dropdown li:first-child" : "toggleDropdown"
}, },

View file

@ -2,7 +2,6 @@ app.views.LikesInfo = app.views.StreamObject.extend({
template_name : "#likes-info-template", template_name : "#likes-info-template",
className : "likes_container", className : "likes_container"
events: { }
}); });

View file

@ -7,7 +7,7 @@ app.views.StreamObject = app.views.Base.extend({
destroyModel: function(evt){ destroyModel: function(evt){
if(evt){ evt.preventDefault(); } if(evt){ evt.preventDefault(); }
if(!confirm("Are you sure?")) { return } if(!confirm(Diaspora.I18n.t("confirm_dialog"))) { return }
this.model.destroy(); this.model.destroy();

View file

@ -2,6 +2,13 @@ describe("app.views.Feedback", function(){
beforeEach(function(){ beforeEach(function(){
window.current_user = app.user({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); window.current_user = app.user({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
Diaspora.I18n.loadLocale({stream : {
'like' : "Like",
'unlike' : "Unlike",
'public' : "Public",
'limited' : "Limted"
}})
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"]; var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
this.post = new app.models.Post(posts[0]); this.post = new app.models.Post(posts[0]);
@ -25,7 +32,7 @@ describe("app.views.Feedback", function(){
context("when the user likes the post", function(){ context("when the user likes the post", function(){
it("the like action should be 'Unlike'", function(){ it("the like action should be 'Unlike'", function(){
expect(this.link().text()).toContain('Unlike'); expect(this.link().text()).toContain(Diaspora.I18n.t('stream.unlike'))
}) })
}) })
@ -37,17 +44,17 @@ describe("app.views.Feedback", function(){
}) })
it("the like action should be 'Like'", function(){ it("the like action should be 'Like'", function(){
expect(this.link().text()).toContain('Like'); expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like'))
}) })
it("allows for unliking a just-liked post", function(){ it("allows for unliking a just-liked post", function(){
expect(this.link().text()).toContain('Like'); expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like'))
this.link().click(); this.link().click();
expect(this.link().text()).toContain('Unlike'); expect(this.link().text()).toContain(Diaspora.I18n.t('stream.unlike'))
this.link().click(); this.link().click();
expect(this.link().text()).toContain('Like'); expect(this.link().text()).toContain(Diaspora.I18n.t('stream.like'))
}) })
}) })
}) })
@ -59,7 +66,7 @@ describe("app.views.Feedback", function(){
}) })
it("shows 'Public'", function(){ it("shows 'Public'", function(){
expect($(this.view.el).html()).toContain('Public') expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.public'))
}) })
it("shows a reshare_action link", function(){ it("shows a reshare_action link", function(){
@ -82,7 +89,7 @@ describe("app.views.Feedback", function(){
}) })
it("shows 'Limited'", function(){ it("shows 'Limited'", function(){
expect($(this.view.el).html()).toContain('Limited') expect($(this.view.el).html()).toContain(Diaspora.I18n.t('stream.limited'))
}) })
it("does not show a reshare_action link", function(){ it("does not show a reshare_action link", function(){

View file

@ -2,6 +2,13 @@ describe("app.views.LikesInfo", function(){
beforeEach(function(){ beforeEach(function(){
window.current_user = app.user({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); window.current_user = app.user({id : -1, name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
Diaspora.I18n.loadLocale({stream : {
likes : {
zero : "<%= count %> Likes",
one : "<%= count %> Like"}
}
})
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"]; var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
this.post = new app.models.Post(posts[0]); // post with a like this.post = new app.models.Post(posts[0]); // post with a like
this.view = new app.views.LikesInfo({model: this.post}); this.view = new app.views.LikesInfo({model: this.post});
@ -11,7 +18,7 @@ describe("app.views.LikesInfo", function(){
it("displays a the like count if it is above zero", function() { it("displays a the like count if it is above zero", function() {
this.view.render(); this.view.render();
expect($(this.view.el).text()).toContain(this.view.model.get("likes_count")) expect($(this.view.el).text()).toContain(Diaspora.I18n.t('stream.likes', {count : this.view.model.get("likes_count")}))
}) })
it("does not display the like count if it is zero", function() { it("does not display the like count if it is zero", function() {

View file

@ -2,10 +2,16 @@ describe("app.views.Post", function(){
describe("#render", function(){ describe("#render", function(){
beforeEach(function(){ beforeEach(function(){
// should be jasmine helper
window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}}); window.current_user = app.user({name: "alice", avatar : {small : "http://avatar.com/photo.jpg"}});
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"][0]; Diaspora.I18n.loadLocale({stream : {
reshares : {
one : "<%= count %> reshare",
few : "<%= count %> reshares"
}
}})
var posts = $.parseJSON(spec.readFixture("multi_stream_json"))["posts"];
this.collection = new app.collections.Stream(posts); this.collection = new app.collections.Stream(posts);
this.statusMessage = this.collection.models[0]; this.statusMessage = this.collection.models[0];
@ -14,17 +20,15 @@ describe("app.views.Post", function(){
it("displays a reshare count", function(){ it("displays a reshare count", function(){
this.statusMessage.set({reshares_count : 2}) this.statusMessage.set({reshares_count : 2})
var view = new app.views.Post({model : this.statusMessage}).render(); var view = new app.views.Post({model : this.statusMessage}).render();
var statusElement = $(view.el)
expect(statusElement.html()).toContain("2 reshares") expect(view.$(".post_initial_info").html()).toContain(Diaspora.I18n.t('stream.reshares', {count: 2}))
}) })
it("does not display a reshare count for 'zero'", function(){ it("does not display a reshare count for 'zero'", function(){
this.statusMessage.set({reshares_count : 0}) this.statusMessage.set({reshares_count : 0})
var view = new app.views.Post({model : this.statusMessage}).render(); var view = new app.views.Post({model : this.statusMessage}).render();
var statusElement = $(view.el)
expect(statusElement.html()).not.toContain("0 reshares") expect(view.$(".post_initial_info").html()).not.toContain("0 Reshares")
}) })
context("user not signed in", function(){ context("user not signed in", function(){