summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/layouts/_header.html.haml2
-rw-r--r--app/views/layouts/_navigation.html.haml2
-rw-r--r--config/locales/flash.en.yml10
-rw-r--r--engines/support/app/controllers/tickets_controller.rb2
-rw-r--r--engines/support/app/helpers/tickets_helper.rb14
-rw-r--r--engines/support/app/models/ticket_comment.rb5
-rw-r--r--engines/support/app/views/tickets/_comment.html.haml5
-rw-r--r--engines/support/app/views/tickets/_edit_form.html.haml29
-rw-r--r--engines/support/app/views/tickets/_new_comment_form.html.haml6
-rw-r--r--engines/support/app/views/tickets/_tabs.html.haml18
-rw-r--r--engines/support/app/views/tickets/index.html.haml10
-rw-r--r--engines/support/app/views/tickets/new.html.haml2
-rw-r--r--engines/support/config/locales/en.yml124
-rw-r--r--lib/extensions/couchrest.rb1
14 files changed, 155 insertions, 75 deletions
diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml
index a1dd47a..fbc46b3 100644
--- a/app/views/layouts/_header.html.haml
+++ b/app/views/layouts/_header.html.haml
@@ -4,7 +4,7 @@
%li{:class => ("active" if controller?('users', 'overviews') || params[:user_id])}
= link_to t(:users), users_path
%li{:class => ("active" if controller?('tickets') && !params[:user_id])}
- = link_to t(:tickets), tickets_path
+ = link_to t(".tickets", cascade: true), tickets_path
%li
= link_to t(:logout), logout_path, :method => :delete
- if @user && @show_navigation
diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml
index b81c43d..94f71f7 100644
--- a/app/views/layouts/_navigation.html.haml
+++ b/app/views/layouts/_navigation.html.haml
@@ -2,6 +2,6 @@
= link_to_navigation t(:overview), @user, :active => (controller?(:users) && action?(:show))
= link_to_navigation t(:account_settings), edit_user_path(@user), :active => (controller?(:users) && !action?(:show))
- # will want link for identity settings
- = link_to_navigation t(:support_tickets), auto_tickets_path, :active => controller?(:tickets)
+ = link_to_navigation t(".tickets"), auto_tickets_path, :active => controller?(:tickets)
= link_to_navigation t(:billing_settings), billing_top_link(@user), :active => controller?(:customer, :payments, :subscriptions, :credit_card_info) if APP_CONFIG[:billing]
= link_to_navigation t(:logout), logout_path, :method => :delete
diff --git a/config/locales/flash.en.yml b/config/locales/flash.en.yml
new file mode 100644
index 0000000..7ad28f8
--- /dev/null
+++ b/config/locales/flash.en.yml
@@ -0,0 +1,10 @@
+en:
+ flash:
+ success: "%{resource} was successfully saved."
+ error: "%{resource} could not be saved."
+ create:
+ success: "%{resource} was successfully created."
+ error: "%{resource} could not be created."
+ update:
+ success: "%{resource} was successfully updated."
+ error: "%{resource} could not be updated."
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb
index 9c1a741..857d071 100644
--- a/engines/support/app/controllers/tickets_controller.rb
+++ b/engines/support/app/controllers/tickets_controller.rb
@@ -81,7 +81,7 @@ class TicketsController < ApplicationController
protected
def set_title
- @title = t(:tickets)
+ @title = t("layouts.title.tickets")
end
private
diff --git a/engines/support/app/helpers/tickets_helper.rb b/engines/support/app/helpers/tickets_helper.rb
index 7af50d6..11b02e4 100644
--- a/engines/support/app/helpers/tickets_helper.rb
+++ b/engines/support/app/helpers/tickets_helper.rb
@@ -35,13 +35,7 @@ module TicketsHelper
#
def link_to_status(new_status)
- if new_status == "open"
- label = t(:open_tickets)
- elsif new_status == "closed"
- label = t(:closed_tickets)
- elsif new_status == "all"
- label = t(:all_tickets)
- end
+ label = t(:".#{new_status}", cascade: true)
link_to label, auto_tickets_path(:open_status => new_status, :sort_order => search_order)
end
@@ -62,11 +56,7 @@ module TicketsHelper
direction = 'desc'
end
- if order_field == 'updated'
- label = t(:updated)
- elsif order_field == 'created'
- label = t(:created)
- end
+ label = t(:".#{order_field}", cascade: true)
link_to auto_tickets_path(:sort_order => order_field + '_at_' + direction, :open_status => search_status) do
arrow + label
diff --git a/engines/support/app/models/ticket_comment.rb b/engines/support/app/models/ticket_comment.rb
index bed5237..2c5df41 100644
--- a/engines/support/app/models/ticket_comment.rb
+++ b/engines/support/app/models/ticket_comment.rb
@@ -18,6 +18,11 @@ class TicketComment
# view :by_body
#end
+ # translations are in the same scope as those of a "proper" couchrest model
+ def self.i18n_scope
+ "couchrest"
+ end
+
def is_comment_validated?
!!posted_by
end
diff --git a/engines/support/app/views/tickets/_comment.html.haml b/engines/support/app/views/tickets/_comment.html.haml
index 778ca13..65ec394 100644
--- a/engines/support/app/views/tickets/_comment.html.haml
+++ b/engines/support/app/views/tickets/_comment.html.haml
@@ -1,4 +1,5 @@
-- if admin? or !comment.private # only show comment if user is admin or comment is not private
+- # only show comment if user is admin or comment is not private
+- if admin? or !comment.private
%tr
%td.user
%div
@@ -17,4 +18,4 @@
%span.label.label-important
= t(:private)
%td.comment
- = simple_format(comment.body) \ No newline at end of file
+ = simple_format(comment.body)
diff --git a/engines/support/app/views/tickets/_edit_form.html.haml b/engines/support/app/views/tickets/_edit_form.html.haml
index 22815f2..522489e 100644
--- a/engines/support/app/views/tickets/_edit_form.html.haml
+++ b/engines/support/app/views/tickets/_edit_form.html.haml
@@ -23,29 +23,24 @@
%p.first
- if @ticket.is_open?
%span.label.label-info
- %b{style: 'padding:10px'}= t(:open)
- = f.button :loading, t(:close), class: 'btn-mini'
+ %b{style: 'padding:10px'}= t("tickets.status.open")
+ = f.button :loading, t("tickets.action.close"), class: 'btn-mini'
- else
%span.label.label-success
- %b{style: 'padding:10px'}= t(:closed)
- = f.button :loading, t(:open), class: 'btn-mini'
- %span.label.label-clear= t(:created_by_on, :user => created_by, :time => @ticket.created_at.to_s(:short)).html_safe
+ %b{style: 'padding:10px'}= t("tickets.status.closed")
+ = f.button :loading, t("tickets.action.open"), class: 'btn-mini'
+ %span.label.label-clear
+ = t("tickets.created_by_on", user: created_by, time: @ticket.created_at.to_s(:short), cascade: true).html_safe
= simple_form_for @ticket do |f|
= hidden_ticket_fields
- %div= t(:subject)
- = f.text_field :subject, :class => 'large full-width'
+ = f.input :subject, input_html: {:class => 'large full-width'}
.row-fluid
.span4
- %div= t(:status)
- = f.select :is_open, [[t(:open), "true"], [t(:closed), "false"]]
+ = f.input :is_open, as: :select, collection: [:true, :false], include_blank: false
.span4
- %div= t(:email)
- = f.text_field :email
+ = f.input :email
.span4
- %div
- = t(:regarding_account)
- = regarding_user_link
- = f.text_field :regarding_user
- = f.button :loading, t(:save), :value => 'save'
+ = f.input :regarding_user, label: Ticket.human_attribute_name(:regarding_user) + regarding_user_link
+ = f.button :loading
- if admin?
- = link_to t(:destroy), auto_ticket_path(@ticket), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn'
+ = link_to t(".destroy", cascade: true), auto_ticket_path(@ticket), :confirm => t("tickets.confirm.destroy.are_you_sure", cascade: true), :method => :delete, :class => 'btn'
diff --git a/engines/support/app/views/tickets/_new_comment_form.html.haml b/engines/support/app/views/tickets/_new_comment_form.html.haml
index 40c737f..b829b6b 100644
--- a/engines/support/app/views/tickets/_new_comment_form.html.haml
+++ b/engines/support/app/views/tickets/_new_comment_form.html.haml
@@ -7,7 +7,7 @@
= c.input :body, :label => false, :as => :text, :input_html => {:class => "full-width", :rows=> 5}
- if admin?
= c.input :private, :as => :boolean, :label => false, :inline_label => true
- = f.button :loading, t(:post_reply), class: 'btn-primary', value: 'post_reply'
+ = f.button :loading, t(".post_reply"), class: 'btn-primary', value: 'post_reply'
- if logged_in? && @ticket.is_open
- = f.button :loading, t(:reply_and_close), value: 'reply_and_close'
- = link_to t(:cancel), auto_tickets_path, :class => :btn
+ = f.button :loading, t(".reply_and_close"), value: 'reply_and_close'
+ = link_to t(".cancel"), auto_tickets_path, :class => :btn
diff --git a/engines/support/app/views/tickets/_tabs.html.haml b/engines/support/app/views/tickets/_tabs.html.haml
index 445a909..7872bb5 100644
--- a/engines/support/app/views/tickets/_tabs.html.haml
+++ b/engines/support/app/views/tickets/_tabs.html.haml
@@ -3,21 +3,17 @@
-#
- unless action?(:new) or action?(:create)
%ul.nav.nav-pills.pull-right.slim
- %li{:class=> ("active" if search_order.start_with? 'created_at')}
- = link_to_order('created')
- %li{:class=> ("active" if search_order.start_with? 'updated_at')}
- = link_to_order('updated')
+ - %w(created updated).each do |order|
+ %li{:class=> ("active" if search_order.start_with? order)}
+ = link_to_order(order)
-#
-# STATUS FILTER TABS
-#
%ul.nav.nav-tabs
- if logged_in?
- %li{:class => ("active" if search_status == 'open')}
- = link_to_status 'open'
- %li{:class => ("active" if search_status == 'closed')}
- = link_to_status 'closed'
- %li{:class => ("active" if search_status == 'all')}
- = link_to_status 'all'
+ - %w(open closed all).each do |status|
+ %li{:class => ("active" if search_status == status)}
+ = link_to_status status
%li{:class => ("active" if action?(:new) || action?(:create))}
- = link_to icon(:plus, :black) + t(:new_ticket), auto_new_ticket_path
+ = link_to icon(:plus, :black) + t(".new", cascade: true), auto_new_ticket_path
diff --git a/engines/support/app/views/tickets/index.html.haml b/engines/support/app/views/tickets/index.html.haml
index a4df6e3..526cd6d 100644
--- a/engines/support/app/views/tickets/index.html.haml
+++ b/engines/support/app/views/tickets/index.html.haml
@@ -5,15 +5,15 @@
%table.table.table-striped.table-bordered
%thead
%tr
- %th= t(:subject)
- %th= t(:created)
- %th= t(:updated)
- %th= t(:voices)
+ %th= t(".subject")
+ %th= t(".created")
+ %th= t(".updated")
+ %th= t(".voices")
%tbody
- if @tickets.any?
= render @tickets.all
- else
%tr
- %td{:colspan=>4}= t(:none)
+ %td{:colspan=>4}= t(".none")
= paginate @tickets
diff --git a/engines/support/app/views/tickets/new.html.haml b/engines/support/app/views/tickets/new.html.haml
index 3de5fe9..d3580f9 100644
--- a/engines/support/app/views/tickets/new.html.haml
+++ b/engines/support/app/views/tickets/new.html.haml
@@ -11,7 +11,7 @@
= f.input :email
= f.input :regarding_user
= f.simple_fields_for :comments, @comment do |c|
- = c.input :body, :label => t(:description), :as => :text, :input_html => {:class => "full-width", :rows=> 5}
+ = c.input :body, :as => :text, :input_html => {:class => "full-width", :rows=> 5}
- if admin?
= c.input :private, :as => :boolean, :label => false, :inline_label => true
= f.button :wrapped, cancel: (logged_in? ? auto_tickets_path : home_path)
diff --git a/engines/support/config/locales/en.yml b/engines/support/config/locales/en.yml
index 342adea..f2caecc 100644
--- a/engines/support/config/locales/en.yml
+++ b/engines/support/config/locales/en.yml
@@ -1,22 +1,104 @@
en:
- access_ticket_text: >
- You can later access this ticket at the URL %{full_url}. You might want to bookmark this page to find it again.
- Anybody with this URL will be able to access this ticket, so if you are on a shared computer you might want to
- remove it from the browser history.
- support_tickets: "Support Tickets"
- all_tickets: "All Tickets"
- my_tickets: "My Tickets"
- open_tickets: "Open Tickets"
- closed_tickets: "Closed Tickets"
- new_ticket: "New Ticket"
- tickets: "Tickets"
- subject: "Subject"
- destroy: "Destroy"
- open: "Open"
- closed: "Closed"
- close: "Close"
- post_reply: "Post Reply"
- reply_and_close: "Reply and Close"
- description: "Description"
- ticket: "Ticket"
- regarding_account: "Regarding Account" \ No newline at end of file
+ # translations used in the layout views or @title
+ layouts:
+ # fallback for all translations of "tickets" nested below:
+ tickets: "Tickets"
+ title:
+ tickets: "Tickets"
+ header:
+ tickets: "Tickets"
+ navigation:
+ tickets: "Support Tickets"
+ # Translations used in the views inside the tickets directory
+ tickets:
+ # If these do not exist they will be looked up in the global scope.
+ all: "All Tickets"
+ open: "Open Tickets"
+ closed: "Closed Tickets"
+ new: "New Ticket"
+ created: "Created at"
+ updated: "Updated at"
+ subject: "couchrest.models.tickets.attributes.subject"
+ status:
+ open: "Open"
+ closed: "Closed"
+ action:
+ open: "Open"
+ close: "Close"
+ confirm:
+ destroy:
+ are_you_sure: "Are you sure you want to destroy this ticket?"
+ # If you want to be more specific you can use the partial as a scope:
+ tabs:
+ all: "All Tickets"
+ open: "Open Tickets"
+ closed: "Closed Tickets"
+ index:
+ none: "No tickets have been found."
+ voices: "Voices"
+ destroy: "Destroy"
+ post_reply: "Post Reply"
+ reply_and_close: "Reply and Close"
+ access_ticket_text: >
+ You can later access this ticket at the URL %{full_url}. You might want to bookmark this page to find it again.
+ Anybody with this URL will be able to access this ticket, so if you are on a shared computer you might want to
+ remove it from the browser history.
+ # rails i18n
+ helpers:
+ # translations used for submit buttons. simple form picks these up
+ submit:
+ ticket:
+ create: "Submit Ticket"
+ update: "Update Ticket"
+ # translations for the model and its attributes
+ # serve as fallback for simpleform labels
+ couchrest:
+ models:
+ ticket: "Ticket"
+ ticket_comment: "Comment"
+ attributes:
+ ticket:
+ # these will fallback to translations in the "attributes" scope
+ subject: "Subject"
+ email: "Email"
+ regarding_user: "Regarding User"
+ regarding_account: "Regarding Account"
+ is_open: "Status"
+ ticket_comment:
+ body: "Description"
+ private: "private"
+ simple_form:
+ # labels next to the field
+ labels:
+ # these will fallback to the human_name translations of the model
+ ticket:
+ # these will fallback to translations in "simple_form.labels.defaults"
+ regarding_:
+ # you can be specific about translations for a given action:
+ #edit:
+ # regaring_user:
+ email: "Email"
+ comments:
+ # these will fall back to "simple_form.labels.comments"
+ body: "Description"
+ # comments: ~
+ options:
+ ticket:
+ is_open:
+ "true": "Open"
+ "false": "Closed"
+ # mouse over hints for the given fields
+ hints:
+ ticket:
+ email: "Please provide an email address so we can get back to you."
+ # these will fallback to translations in "simple_form.hints.defaults"
+ # placeholders inside the fields before anything was typed
+ #placeholders:
+ # ticket: ~
+ # these will fallback to translations in "simple_form.placeholders.defaults"
+
+ # these are generic defaults. They should be moved into the toplevel
+ # attributes:
+ #simple_form:
+ #labels:
+ # defaults:
diff --git a/lib/extensions/couchrest.rb b/lib/extensions/couchrest.rb
index 0e5051a..df83c9f 100644
--- a/lib/extensions/couchrest.rb
+++ b/lib/extensions/couchrest.rb
@@ -2,6 +2,7 @@ module CouchRest
module Model
class Base
extend ActiveModel::Naming
+ extend ActiveModel::Translation
end
module Designs