From d6f5b7512d15e9ae23c569f1fbd760e0ebdb3f07 Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Tue, 12 Aug 2014 13:41:14 +0200 Subject: [PATCH] i18n for all new pages --- app/locale/en.coffee | 43 ++++++++++++++ .../account/{home.sass => account_home.sass} | 2 +- app/styles/achievements.sass | 15 +++-- app/styles/common/top_nav.sass | 8 +-- app/styles/user/home.sass | 2 +- .../account/{home.jade => account_home.jade} | 55 +++++++++--------- .../achievements/achievement-popup.jade | 9 ++- app/templates/base.jade | 14 ++--- .../editor/level/modal/new-achievement.jade | 8 +-- .../editor/level/related-achievements.jade | 8 +-- app/templates/user/achievements.jade | 12 ++-- .../user/{home.jade => user_home.jade} | 58 +++++++++---------- app/views/account/MainAccountView.coffee | 12 ++-- .../achievements/AchievementPopup.coffee | 1 + app/views/user/MainUserView.coffee | 4 +- 15 files changed, 151 insertions(+), 100 deletions(-) rename app/styles/account/{home.sass => account_home.sass} (95%) rename app/templates/account/{home.jade => account_home.jade} (67%) rename app/templates/user/{home.jade => user_home.jade} (65%) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 2b8549b5e..43fe6fc8c 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -49,6 +49,9 @@ blog: "Blog" forum: "Forum" account: "Account" + profile: "Profile" + stats: "Stats" + code: "Code" admin: "Admin" home: "Home" contribute: "Contribute" @@ -176,12 +179,14 @@ new_password: "New Password" new_password_verify: "Verify" email_subscriptions: "Email Subscriptions" + email_subscriptions_none: "No Email Subscriptions." email_announcements: "Announcements" email_announcements_description: "Get emails on the latest news and developments at CodeCombat." email_notifications: "Notifications" email_notifications_summary: "Controls for personalized, automatic email notifications related to your CodeCombat activity." email_any_notes: "Any Notifications" email_any_notes_description: "Disable to stop all activity notification emails." + email_news: "News" email_recruit_notes: "Job Opportunities" email_recruit_notes_description: "If you play really well, we may contact you about getting you a (better) job." contributor_emails: "Contributor Class Emails" @@ -555,6 +560,10 @@ level_search_title: "Search Levels Here" achievement_search_title: "Search Achievements" read_only_warning2: "Note: you can't save any edits here, because you're not logged in." + no_achievements: "No achievements have been added for this level yet." + achievement_query_misc: "Key achievement off of miscellanea" + achievement_query_goals: "Key achievement off of level goals" + level_completion: "Level Completion" article: edit_btn_preview: "Preview" @@ -563,6 +572,7 @@ general: and: "and" name: "Name" + date: "Date" body: "Body" version: "Version" commit_msg: "Commit Message" @@ -916,3 +926,36 @@ text_diff: "Text Diff" merge_conflict_with: "MERGE CONFLICT WITH" no_changes: "No Changes" + + user: + stats: "Stats" + singleplayer_title: "Singleplayer Levels" + multiplayer_title: "Multiplayer Levels" + achievements_title: "Achievements" + last_played: "Last Played" + status: "Status" + status_completed: "Completed" + status_unfinished: "Unfinished" + no_singleplayer: "No Singleplayer games played yet." + no_multiplayer: "No Multiplayer games played yet." + no_achievements: "No Achievements earned yet." + + achievements: + last_earned: "Last Earned" + amount_achieved: "Amount" + achievement: "Achievement" + category_contributor: "Contributor" + category_miscellaneous: "Miscellaneous" + category_levels: "Levels" + category_undefined: "Uncategorized" + current_xp_prefix: "" + current_xp_postfix: " in total" + new_xp_prefix: "" + new_xp_postfix: " earned" + left_xp_prefix: "" + left_xp_infix: " until level " + left_xp_postfix: "" + + account: + recently_played: "Recently Played" + no_recent_games: "No games played during the past two weeks." diff --git a/app/styles/account/home.sass b/app/styles/account/account_home.sass similarity index 95% rename from app/styles/account/home.sass rename to app/styles/account/account_home.sass index 3e695687c..800c8a8b2 100644 --- a/app/styles/account/home.sass +++ b/app/styles/account/account_home.sass @@ -1,7 +1,7 @@ @import "../bootstrap/variables" @import "../bootstrap/mixins" -#account-home-view +#account-home dl margin-bottom: 0px diff --git a/app/styles/achievements.sass b/app/styles/achievements.sass index 574734048..1ae6a7ff8 100644 --- a/app/styles/achievements.sass +++ b/app/styles/achievements.sass @@ -128,18 +128,13 @@ bottom: 48px .user-level - background-image: url("/images/achievements/level-bg.png") - color: white - width: 38px - height: 38px - line-height: 38px font-size: 20px + color: white position: absolute left: -15px margin-top: -8px vertical-align: middle z-index: 1000 - font-family: $font-family-base > .progress-bar-wrapper position: absolute @@ -237,3 +232,11 @@ .popup cursor: default left: 600px + +.user-level + background-image: url("/images/achievements/level-bg.png") + width: 38px + height: 38px + line-height: 38px + font-size: 20px + font-family: $font-family-base diff --git a/app/styles/common/top_nav.sass b/app/styles/common/top_nav.sass index 129070977..42e7fce47 100644 --- a/app/styles/common/top_nav.sass +++ b/app/styles/common/top_nav.sass @@ -94,12 +94,8 @@ a.disabled color: #31281E .user-level position: absolute - top: 85px - right: 100px - font-size: 20px - border-radius: 50% - background-color: #FFE4BC - box-shadow: 0 0 0 1px black // disable for double border + top: 73px + right: 86px color: gold text-shadow: 1px 1px black, -1px -1px 0 black, 1px -1px 0 black, -1px 1px 0 black diff --git a/app/styles/user/home.sass b/app/styles/user/home.sass index c7b546508..55eec3fb2 100644 --- a/app/styles/user/home.sass +++ b/app/styles/user/home.sass @@ -1,7 +1,7 @@ @import "../bootstrap/variables" @import "../bootstrap/mixins" -#user-home-view +#user-home margin-top: 20px .left-column diff --git a/app/templates/account/home.jade b/app/templates/account/account_home.jade similarity index 67% rename from app/templates/account/home.jade rename to app/templates/account/account_home.jade index df897a358..d59a411df 100644 --- a/app/templates/account/home.jade +++ b/app/templates/account/account_home.jade @@ -4,8 +4,9 @@ block content if !me.isAnonymous() .clearfix .col-sm-6.clearfix - h2 Account Settings - a.spl(href="settings") + h2 + span(data-i18n="account_settings.title") Account Settings + a.spl(href="/account/settings") i.glyphicon.glyphicon-cog hr .row @@ -14,15 +15,15 @@ block content .panel-heading h3.panel-title i.glyphicon.glyphicon-picture - a(href="account/settings#picture") Picture + a(href="account/settings#picture" data-i18n="account_settings.picture_tab") Picture .panel-body.text-center - img#picture(src="#{me.getPhotoURL(150)}" alt="") + img#picture(src="#{me.getPhotoURL(150)}" alt="Picture") .col-xs-6 .panel.panel-default .panel-heading h3.panel-title i.glyphicon.glyphicon-user - a(href="account/settings#wizard") Wizard + a(href="account/settings#wizard" data-i18n="account_settings.wizard_tab") Wizard if (wizardSource) .panel-body.text-center img(src="#{wizardSource}") @@ -30,35 +31,37 @@ block content .panel-heading h3.panel-title i.glyphicon.glyphicon-user - a(href="account/settings#me") Me + a(href="account/settings#me" data-i18n="account_settings.me_tab") Me .panel-body table tr - th Name - td=me.get('name') || 'Anoner' + th(data-i18n="general.name") Name + td=me.displayName() tr - th Email + th(data-i18n="general.email") Email td=me.get('email') .panel.panel-default.panel-emails .panel-heading h3.panel-title i.glyphicon.glyphicon-envelope - a(href="account/settings#emails") Emails + a(href="account/settings#emails" data-i18n="account_settings.emails_tab") Emails .panel-body - if !hasEmailNotes && !hasEmailNews - p No email subscriptions. + if !hasEmailNotes && !hasEmailNews && !hasGeneralNews + p(data-i18n="account_settings.email_subscriptions_none") No email subscriptions. + if hasGeneralNews + h4(data-i18n="account_settings.email_news") News + ul + li(data-i18n="account_settings.email_announcements") Announcements if hasEmailNotes - h4 Notifications + h4(data-i18n="account_settings.email_notifications") Notifications ul if subs.anyNotes li(data-i18n="account_settings.email_any_notes") Any Notifications if subs.recruitNotes li(data-i18n="account_settings.email_recruit_notes") Job Opportunities if hasEmailNews - h4 News + h4(data-i18n="account_settings.contributor_emails") Contributor Emails ul - if (subs.generalNews) - li(data-i18n="account_settings.email_announcements") General if (subs.archmageNews) li span(data-i18n="classes.archmage_title") @@ -100,23 +103,23 @@ block content .panel-heading h3.panel-title i.glyphicon.glyphicon-wrench - a(href="account/settings#password") Password + a(href="account/settings#password" data-i18n="general.password") Password .panel.panel-default .panel-heading h3.panel-title i.glyphicon.glyphicon-briefcase - a(href="account/settings#job-profile") Job Profile + a(href="account/settings#job-profile" data-i18n="account_settings.job_profile") Job Profile .col-sm-6 - h2 Recently Played + h2(data-i18n="user.recently_played") Recently Played hr if !recentlyPlayed - div Loading... + div(data-i18n="common.loading") Loading... else if recentlyPlayed.length table.table tr - th Level - th Last Played - th Status + th(data-i18n="resources.level") Level + th(data-i18n="user.last_played") Last Played + th(data-i18n="user.status") Status each session in recentlyPlayed if session.get('levelName') tr @@ -126,13 +129,13 @@ block content a(href="/play/level/#{session.get('levelID') + posturl}")= session.get('levelName') + (session.get('team') ? ' (' + session.get('team') + ')' : '') td= moment(session.get('changed')).fromNow() if session.get('state').complete === true - td Completed + td(data-i18n="user.status_completed") Completed else if ! session.isMultiplayer() - td Unfinished + td(data-i18n="user.status_unfinished") Unfinished else td else .panel.panel-default .panel-body - div No games played during the past two weeks. + div(data-i18n="account.no_recent_games") No games played during the past two weeks. diff --git a/app/templates/achievements/achievement-popup.jade b/app/templates/achievements/achievement-popup.jade index f3cca98e4..f3e53d4dc 100644 --- a/app/templates/achievements/achievement-popup.jade +++ b/app/templates/achievements/achievement-popup.jade @@ -12,7 +12,10 @@ span.user-level= level .progress-bar-wrapper .progress - .progress-bar.xp-bar-old(style="width:#{oldXPWidth}%" data-toggle="tooltip" data-placement="top" title="#{currentXP} XP in total") - .progress-bar.xp-bar-new(style="width:#{newXPWidth}%" data-toggle="tooltip" title="#{newXP} XP earned") - .progress-bar.xp-bar-left(style="width:#{leftXPWidth}%" data-toggle="tooltip" title="#{leftXP} XP until level #{level+1}") + - var currentTitle = $.i18n.t('achievements.current_xp_prefix') + currentXP + ' XP' + $.i18n.t('achievements.current_xp_postfix'); + - var newTitle = $.i18n.t('achievements.new_xp_prefix') + newXP + ' XP' + $.i18n.t('achievements.new_xp_postfix'); + - var leftTitle = $.i18n.t('achievements.left_xp_prefix') + newXP + ' XP' + $.i18n.t('achievements.left_xp_infix') + (level+1) + $.i18n.t('achievements.left_xp_postfix'); + .progress-bar.xp-bar-old(style="width:#{oldXPWidth}%" data-toggle="tooltip" data-placement="top" title="#{currentTitle}") + .progress-bar.xp-bar-new(style="width:#{newXPWidth}%" data-toggle="tooltip" title="#{newTitle}") + .progress-bar.xp-bar-left(style="width:#{leftXPWidth}%" data-toggle="tooltip" title="#{leftTitle}") .progress-bar-border diff --git a/app/templates/base.jade b/app/templates/base.jade index fe9158497..a5f9c29bb 100644 --- a/app/templates/base.jade +++ b/app/templates/base.jade @@ -43,20 +43,20 @@ body span.caret ul.dropdown-menu(role="menu") li.user-dropdown-header - span.user-level.badge= me.level() - a(href="/user/#{me.get('slug') || me.get('_id')}") + span.user-level= me.level() + a(href="/user/#{me.getSlugOrID()}") img.img-circle(src="#{me.getPhotoURL()}" alt="") - h3=me.get('name') || 'Anoner' + h3=me.displayName() li.user-dropdown-body .col-xs-4.text-center - a(href="/user/#{me.get('slug') || me.get('_id')}") Profile + a(href="/user/#{me.getSlugOrID()}" data-i18n="nav.profile") Profile .col-xs-4.text-center - a(href="/user/#{me.get('slug') || me.get('_id')}/stats") Stats + a(href="/user/#{me.getSlugOrID()}/stats" data-i18n="nav.stats") Stats .col-xs-4.text-center - a.disabled() Code + a.disabled(data-i18n="nav.code") Code li.user-dropdown-footer .pull-left - a.btn.btn-default.btn-flat(href="/account") Account + a.btn.btn-default.btn-flat(href="/account" data-i18n="nav.account") Account .pull-right button#logout-button.btn.btn-default.btn-flat(data-i18n="login.log_out") Log Out else diff --git a/app/templates/editor/level/modal/new-achievement.jade b/app/templates/editor/level/modal/new-achievement.jade index f66347278..dfcc39cbc 100644 --- a/app/templates/editor/level/modal/new-achievement.jade +++ b/app/templates/editor/level/modal/new-achievement.jade @@ -6,16 +6,16 @@ block modal-body-content label.control-label(for="name", data-i18n="general.name") Name input#name.form-control(name="name", type="text") .form-group - label.control-label(for="description") Description + label.control-label(for="description" data-i18n="general.description") Description input#description.form-control(name="description", type="text") - h4 Miscellaneous achievement keys + h4(data-i18n="editor.achievement_query_misc") Key achievement off of miscellanea .radio label input(type="checkbox", name="queryOptions" id="misc-level-completion" value="misc-level-completion") - span.spl Level Completion + span.spl(data-i18n="editor.level_completion") Level Completion - var goals = level.get('goals'); if goals && goals.length - h4 Base achievement on goals? + h4(data-i18n="editor.achievement_query_goals") Key achievement off of level goals each goal in goals .radio label diff --git a/app/templates/editor/level/related-achievements.jade b/app/templates/editor/level/related-achievements.jade index 9270c0def..e0312d779 100644 --- a/app/templates/editor/level/related-achievements.jade +++ b/app/templates/editor/level/related-achievements.jade @@ -2,18 +2,18 @@ button.btn.btn-primary#new-achievement-button(disabled=me.isAdmin() === true ? undefined : "true" data-i18n="editor.new_achievement_title") Create a New Achievement if achievements.loading - h2 Loading... + h2(data-i18n="common.loading") Loading... else if ! achievements.models.length .panel .panel-body - p No achievements added for this level yet. + p(data-i18n="editor.no_achievements") No achievements added for this level yet. else table.table.table-hover thead tr th - th Name - th Description + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description th XP tbody each achievement in achievements.models diff --git a/app/templates/user/achievements.jade b/app/templates/user/achievements.jade index b84b63e17..37cbad2b3 100644 --- a/app/templates/user/achievements.jade +++ b/app/templates/user/achievements.jade @@ -9,7 +9,7 @@ block append content .grid-layout each achievements, category in achievementsByCategory .row - h2.achievement-category-title=category.charAt(0).toUpperCase() + category.slice(1) + h2.achievement-category-title(data-i18n="category_#{category}")=category each achievement, index in achievements - var title = achievement.get('name'); - var description = achievement.get('description'); @@ -27,10 +27,10 @@ block append content if earnedAchievements.length table.table tr - th Name - th Description - th Date - th Amount + th(data-i18n="general.name") Name + th(data-i18n="general.description") Description + th(data-i18n="general.date") Date + th(data-i18n="achievements.amount_achieved") Amount th XP each earnedAchievement in earnedAchievements.models - var achievement = earnedAchievement.get('achievement'); @@ -45,6 +45,6 @@ block append content td= earnedAchievement.get('earnedPoints') else .panel#no-achievements - .panel-body No achievements earned yet. + .panel-body(data-i18n="user.no_achievements") No achievements earned yet. else div How did you even do that? diff --git a/app/templates/user/home.jade b/app/templates/user/user_home.jade similarity index 65% rename from app/templates/user/home.jade rename to app/templates/user/user_home.jade index e9aedd463..d3e6f22db 100644 --- a/app/templates/user/home.jade +++ b/app/templates/user/user_home.jade @@ -15,13 +15,13 @@ block append content .btn-group-vertical.profile-menu a.btn.btn-default(href="/user/#{user.getSlugOrID()}/profile") i.glyphicon.glyphicon-briefcase - span Job Profile + span(data-i18n="account_settings.job_profile") Job Profile a.btn.btn-default(href="/user/#{user.getSlugOrID()}/stats") i.glyphicon.glyphicon-certificate - span Stats + span(data-i18n="user.stats") Stats a.btn.btn-default.disabled(href="#") i.glyphicon.glyphicon-pencil - span Code + span(data-i18n="general.code") Code - var emails = user.get('emails') if emails ul.contributor-categories @@ -32,41 +32,41 @@ block append content li.contributor-category img.contributor-image(src="/images/pages/user/adventurer.png") h4.contributor-title - a(href="/contribute#adventurer") Adventurer + a(href="/contribute#adventurer" data-i18n="classes.adventurer_title") Adventurer if emails.ambassadorNews li.contributor-category img.contributor-image(src="/images/pages/user/ambassador.png") h4.contributor-title - a(href="/contribute#ambassador") Ambassador + a(href="/contribute#ambassador" data-i18n="classes.ambassador_title") Ambassador if emails.archmageNews li.contributor-category img.contributor-image(src="/images/pages/user/archmage.png") h4.contributor-title - a(href="/contribute#archmage") Archmage + a(href="/contribute#archmage" data-i18n="classes.archmage_title") Archmage if emails.artisanNews li.contributor-category img.contributor-image(src="/images/pages/user/artisan.png") h4.contributor-title - a(href="/contribute#artisan") Artisan + a(href="/contribute#artisan" data-i18n="classes.artisan_title") Artisan if emails.scribeNews li.contributor-category img.contributor-image(src="/images/pages/user/scribe.png") h4.contributor-title - a(href="/contribute#scribe") Scribe + a(href="/contribute#scribe" data-i18n="classes.scribe_title") Scribe .right-column .panel.panel-default .panel-heading - h3.panel-title Singleplayer Levels + h3.panel-title(data-i18n="user.singleplayer_title") Singleplayer Levels if (!singlePlayerSessions) .panel-body - p Loading... + p(data-i18n="common.loading") Loading... else if (singlePlayerSessions.length) table.table tr - th.col-xs-4 Level - th.col-xs-4 Last Played - th.col-xs-4 Status + th.col-xs-4(data-i18n="resources.level") Level + th.col-xs-4(data-i18n="user.last_played") Last Played + th.col-xs-4(data-i18n="user.status") Status each session in singlePlayerSessions if session.get('levelName') tr @@ -74,24 +74,24 @@ block append content a(href="/play/level/#{session.get('levelID')}")= session.get('levelName') td= moment(session.get('changed')).fromNow() if session.get('state').complete === true - td Completed + td(data-i18n="user.status_completed") Completed else - td Unfinished + td(data-i18n="user.status_unfinished") Unfinished else .panel-body - p No Singleplayer games played yet. + p(data-i18n="no_singleplayer") No Singleplayer games played yet. .panel.panel-default .panel-heading - h3.panel-title Multiplayer Levels + h3.panel-title(data-i18n="no_multiplayer") Multiplayer Levels if (!multiPlayerSessions) .panel-body - p Loading... + p(data-i18n="common.loading") Loading... else if (multiPlayerSessions.length) table.table tr - th.col-xs-4 Level - th.col-xs-4 Last Played - th.col-xs-4 Score + th.col-xs-4(data-i18n="resources.level") Level + th.col-xs-4(data-i18n="user.last_played") Last Played + th.col-xs-4(data-i18n="general.score") Score each session in multiPlayerSessions tr td @@ -102,25 +102,25 @@ block append content if session.get('totalScore') td= session.get('totalScore') * 100 else - td Unfinished + td(data-i18n="user.status_unfinished") Unfinished else .panel-body - p No Multiplayer games played yet. + p(data-i18n="user.no_multiplayer") No Multiplayer games played yet. .panel.panel-default .panel-heading - h3.panel-title Achievements + h3.panel-title(data-i18n="user.achievements") Achievements if ! earnedAchievements .panel-body - p Loading... + p(data-i18n="common.loading") Loading... else if ! earnedAchievements.length .panel-body - p No achievements earned so far. + p(data-i18n="user.no_achievements") No achievements earned so far. else table.table tr - th.col-xs-4 Achievement - th.col-xs-4 Last Earned - th.col-xs-4 Amount + th.col-xs-4(data-i18n="achievements.achievement") Achievement + th.col-xs-4(data-i18n="achievements.last_earned") Last Earned + th.col-xs-4(data-i18n="achievements.amount_achieved") Amount each achievement in earnedAchievements.models tr td= achievement.get('achievementName') diff --git a/app/views/account/MainAccountView.coffee b/app/views/account/MainAccountView.coffee index 50d7360be..a14e2192a 100644 --- a/app/views/account/MainAccountView.coffee +++ b/app/views/account/MainAccountView.coffee @@ -1,5 +1,5 @@ View = require 'views/kinds/RootView' -template = require 'templates/account/home' +template = require 'templates/account/account_home' {me} = require 'lib/auth' User = require 'models/User' AuthModalView = require 'views/modal/AuthModal' @@ -7,7 +7,7 @@ RecentlyPlayedCollection = require 'collections/RecentlyPlayedCollection' ThangType = require 'models/ThangType' module.exports = class MainAccountView extends View - id: 'account-home-view' + id: 'account-home' template: template constructor: (options) -> @@ -24,9 +24,11 @@ module.exports = class MainAccountView extends View getRenderData: -> c = super() c.subs = {} - c.subs[sub] = 1 for sub in c.me.getEnabledEmails() - c.hasEmailNotes = _.any c.me.getEnabledEmails(), (sub) -> sub.contains 'Notes' - c.hasEmailNews = _.any c.me.getEnabledEmails(), (sub) -> sub.contains 'News' + enabledEmails = c.me.getEnabledEmails() + c.subs[sub] = 1 for sub in enabledEmails + c.hasEmailNotes = _.any enabledEmails, (sub) -> sub.contains 'Notes' + c.hasEmailNews = _.any enabledEmails, (sub) -> sub.contains('News') and sub isnt 'generalNews' + c.hasGeneralNews = 'generalNews' in enabledEmails c.wizardSource = @wizardType.getPortraitSource colorConfig: me.get('wizard')?.colorConfig if @wizardType.loaded c.recentlyPlayed = @recentlyPlayed.models c diff --git a/app/views/achievements/AchievementPopup.coffee b/app/views/achievements/AchievementPopup.coffee index c8e68760f..e1307a4b7 100644 --- a/app/views/achievements/AchievementPopup.coffee +++ b/app/views/achievements/AchievementPopup.coffee @@ -58,6 +58,7 @@ module.exports = class AchievementPopup extends CocoView _.extend c, @calculateData() c.style = @achievement.getStyle() c.popup = true + c.$ = $ # Allows the jade template to do i18n c render: -> diff --git a/app/views/user/MainUserView.coffee b/app/views/user/MainUserView.coffee index cf0913913..a200ab989 100644 --- a/app/views/user/MainUserView.coffee +++ b/app/views/user/MainUserView.coffee @@ -1,7 +1,7 @@ UserView = require 'views/kinds/UserView' CocoCollection = require 'collections/CocoCollection' LevelSession = require 'models/LevelSession' -template = require 'templates/user/home' +template = require 'templates/user/user_home' {me} = require 'lib/auth' EarnedAchievementCollection = require 'collections/EarnedAchievementCollection' @@ -13,7 +13,7 @@ class LevelSessionsCollection extends CocoCollection super() module.exports = class MainUserView extends UserView - id: 'user-home-view' + id: 'user-home' template: template constructor: (userID, options) ->