Permalink
Browse files

js i18n

  • Loading branch information...
1 parent 0fd8fb1 commit db1f661ffdde2d8bdceb3453df415367ba047890 @ajb ajb committed Apr 8, 2013
Showing with 157 additions and 58 deletions.
  1. +1 −0 Gemfile
  2. +3 −0 Gemfile.lock
  3. +3 −0 app/assets/javascripts/application.js
  4. +2 −0 app/assets/javascripts/i18n.extensions.js.coffee
  5. +1 −1 app/assets/templates/admin_question/question.jst.hamlc
  6. +2 −1 app/assets/templates/admin_response_field/edit/base.jst.hamlc
  7. +2 −2 app/assets/templates/admin_response_field/edit/checkboxes.jst.hamlc
  8. +7 −5 app/assets/templates/admin_response_field/edit/dropdown.jst.hamlc
  9. +1 −1 app/assets/templates/admin_response_field/edit/pieces/description.jst.hamlc
  10. +1 −1 app/assets/templates/admin_response_field/edit/pieces/integer_only.jst.hamlc
  11. +1 −1 app/assets/templates/admin_response_field/edit/pieces/key_field.jst.hamlc
  12. +1 −1 app/assets/templates/admin_response_field/edit/pieces/label.jst.hamlc
  13. +2 −2 app/assets/templates/admin_response_field/edit/pieces/min_max.jst.hamlc
  14. +4 −4 app/assets/templates/admin_response_field/edit/pieces/min_max_length.jst.hamlc
  15. +1 −1 app/assets/templates/admin_response_field/edit/pieces/required.jst.hamlc
  16. +4 −4 app/assets/templates/admin_response_field/edit/pieces/size.jst.hamlc
  17. +1 −1 app/assets/templates/admin_response_field/edit/pieces/units.jst.hamlc
  18. +5 −3 app/assets/templates/admin_response_field/edit/radio.jst.hamlc
  19. +3 −3 app/assets/templates/admin_response_field/form_options.jst.hamlc
  20. +23 −23 app/assets/templates/admin_response_field/page.jst.hamlc
  21. +1 −1 app/assets/templates/admin_response_field/view/base.jst.hamlc
  22. +0 −2 config/application.rb
  23. +25 −0 config/i18n-js.yml
  24. +61 −0 config/locales/client.en.yml
  25. +2 −1 config/locales/{en.yml → server.en.yml}
View
@@ -27,6 +27,7 @@ gem 'acts_as_singleton'
gem 'bootstrap-wysihtml5-rails'
gem 'sanitize'
gem 'impressionist'
+gem 'i18n-js'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
View
@@ -154,6 +154,8 @@ GEM
multi_xml (>= 0.5.2)
httpclient (2.3.3)
i18n (0.6.1)
+ i18n-js (2.1.2)
+ i18n
immigrant (0.1.4)
activerecord (>= 3.0)
foreigner (>= 1.2.1)
@@ -316,6 +318,7 @@ DEPENDENCIES
haml_coffee_assets
heroku_san
httparty
+ i18n-js
immigrant
impressionist
jquery-rails
@@ -11,6 +11,9 @@
// GO AFTER THE REQUIRES BELOW.
//
//= require_self
+//= require i18n
+//= require i18n/translations
+//= require i18n.extensions
//= require prototype_hacks
//= require moment.min
//= require jquery
@@ -0,0 +1,2 @@
+I18n.js = (scope, args) ->
+ I18n.t('js.'+scope, args)
@@ -4,4 +4,4 @@
%td
%textarea= @answer_body || ''
%td
- %button.btn.btn-inverse{"data-backbone-save" => "true", "data-loading-text" => "Saving..."} Save
+ %button.btn.btn-inverse{"data-backbone-save" => "true", "data-loading-text" => I18n.js('saving')}= I18n.js('save')
@@ -1,5 +1,6 @@
%h5
- Editing "<span data-rv-text="model.label"></span>"
+ = I18n.js('editing')
+ "<span data-rv-text="model.label"></span>"
%i.icon-arrow-right.pull-right
.edit-subtemplate-wrapper
@@ -4,6 +4,6 @@
%label.checkbox
%input{"type" => "text", "data-rv-value" => "option:label"}
%input{"type" => "checkbox", "data-rv-checked" => "option:checked"}
- %a.backbone-remove-option remove
+ %a.backbone-remove-option= I18n.js('remove')
-%a.backbone-add-option Add Option
+%a.backbone-add-option= I18n.js('response_field.add_option')
@@ -2,20 +2,22 @@
%label.checkbox
%input{"type" => "checkbox", "data-rv-checked" => "model.field_options.include_blank_option"}
- Include blank option
+ = I18n.js('response_field.include_blank')
%table.table.dropdown-options-table
%thead
%tr
- %th Default?
- %th Value
+ %th= I18n.js('response_field.is_default')
+ %th= I18n.js('response_field.value')
%tbody
%tr{"data-rv-each-option" => "model.field_options.options"}
%td
%input{"type" => "checkbox", "data-rv-checked" => "option:checked", "data-backbone-defaultoption" => "true"}
%td
%input{"type" => "text", "data-rv-value" => "option:label"}
- %a.backbone-remove-option remove <span data-rv-text="index"></span></a>
+ %a.backbone-remove-option
+ = I18n.js('remove')
+ <span data-rv-text="index"></span></a>
-%a.backbone-add-option Add Option
+%a.backbone-add-option= I18n.js('response_field.add_option')
@@ -1,2 +1,2 @@
-%label description
+%label= I18n.js('response_field.description')
%textarea{"data-rv-value" => "model.field_options.description"}
@@ -1,3 +1,3 @@
%label.checkbox
- integer only?
+ = I18n.js('response_field.integer_only')
%input{"type" => "checkbox", "data-rv-checked" => "model.field_options.integer_only"}
@@ -1,3 +1,3 @@
%label.checkbox
- key field?
+ = I18n.js('response_field.key_field')
%input{"type" => "checkbox", "data-rv-checked" => "model.key_field"}
@@ -1,2 +1,2 @@
-%label label
+%label= I18n.js('response_field.label')
%input{"type" => "text", "data-rv-value" => "model.label"}
@@ -1,5 +1,5 @@
-%label min
+%label= I18n.js('response_field.min')
%input.span2{"type" => "text", "data-rv-value" => "model.field_options.min"}
-%label max
+%label= I18n.js('response_field.max')
%input.span2{"type" => "text", "data-rv-value" => "model.field_options.max"}
@@ -1,9 +1,9 @@
-%label min length
+%label= I18n.js('response_field.min_length')
.input-append
%input.span2{"type" => "text", "data-rv-value" => "model.field_options.minlength"}
- %span.add-on characters
+ %span.add-on= I18n.js('characters')
-%label max length
+%label= I18n.js('response_field.max_length')
.input-append
%input.span2{"type" => "text", "data-rv-value" => "model.field_options.maxlength"}
- %span.add-on characters
+ %span.add-on= I18n.js('characters')
@@ -1,3 +1,3 @@
%label.checkbox
- required?
+ = I18n.js('response_field.required')
%input{"type" => "checkbox", "data-rv-checked" => "model.field_options.required"}
@@ -1,5 +1,5 @@
-%label size
+%label= I18n.js('response_field.size')
%select{"data-rv-value" => "model.field_options.size"}
- %option{"value" => "small"} Small
- %option{"value" => "medium"} Medium
- %option{"value" => "large"} Large
+ %option{"value" => "small"}= I18n.js('response_field.small')
+ %option{"value" => "medium"}= I18n.js('response_field.medium')
+ %option{"value" => "large"}= I18n.js('response_field.large')
@@ -1,2 +1,2 @@
-%label units
+%label= I18n.js('response_field.units')
%input{"type" => "text", "data-rv-value" => "model.field_options.units"}
@@ -2,11 +2,13 @@
%label.checkbox
%input{"type" => "radio", "data-backbone-defaultoption" => "true", "data-rv-name" => "model.cid"}
- No default selected
+ = I18n.js('response_field.no_default_selected')
%div{"data-rv-each-option" => "model.field_options.options"}
%input{"type" => "radio", "data-backbone-defaultoption" => "true", "data-rv-checked" => "option:checked", "data-rv-name" => "model.cid"}
%input{"type" => "text", "data-rv-value" => "option:label"}
- %a.backbone-remove-option remove <span data-rv-text="index"></span></a>
+ %a.backbone-remove-option
+ = I18n.js('remove')
+ <span data-rv-text="index"></span></a>
-%a.backbone-add-option Add Option
+%a.backbone-add-option= I18n.js('response_field.add_option')
@@ -1,5 +1,5 @@
-<label>Form Description</label>
+<label>#{I18n.js('response_field.form_description')}</label>
<textarea data-rv-value="project.form_description"></textarea>
-<label>Form Confirmation Message</label>
+<label>#{I18n.js('response_field.form_confirmation_message')}</label>
<textarea data-rv-value="project.form_confirmation_message"></textarea>
-<span class="help-block">If no confirmation message is set, we'll just redirect the vendor to a copy of their bid.</span>
+<span class="help-block">#{I18n.js('response_field.no_confirmation_message')}</span>
@@ -2,25 +2,25 @@
.span5
%ul.nav.nav-tabs#response-field-tabs
%li.active
- %a{"href" => "#addNewField", "data-toggle" => "tab"} Add New Field
+ %a{"href" => "#addNewField", "data-toggle" => "tab"}= I18n.js('response_field.add_new_field')
%li
- %a{"href" => "#editField", "data-toggle" => "tab"} Edit Field
+ %a{"href" => "#editField", "data-toggle" => "tab"}= I18n.js('response_field.edit_field')
%li
- %a{"href" => "#formOptions", "data-toggle" => "tab"} Form Options
+ %a{"href" => "#formOptions", "data-toggle" => "tab"}= I18n.js('response_field.form_options')
.tab-content
.tab-pane.active#addNewField
- %a.btn.btn-small{"data-backbone-add-field" => "text"} Text
- %a.btn.btn-small{"data-backbone-add-field" => "paragraph"} Paragraph
- %a.btn.btn-small{"data-backbone-add-field" => "checkboxes"} Checkboxes
- %a.btn.btn-small{"data-backbone-add-field" => "radio"} Radio
- %a.btn.btn-small{"data-backbone-add-field" => "dropdown"} Dropdown
- %a.btn.btn-small{"data-backbone-add-field" => "price"} Price
- %a.btn.btn-small{"data-backbone-add-field" => "number"} Number
- %a.btn.btn-small{"data-backbone-add-field" => "date"} Date
- %a.btn.btn-small{"data-backbone-add-field" => "time"} Time
- %a.btn.btn-small{"data-backbone-add-field" => "website"} Website
- %a.btn.btn-small{"data-backbone-add-field" => "file"} File
+ %a.btn.btn-small{"data-backbone-add-field" => "text"}= I18n.js('field_types.text')
+ %a.btn.btn-small{"data-backbone-add-field" => "paragraph"}= I18n.js('field_types.paragraph')
+ %a.btn.btn-small{"data-backbone-add-field" => "checkboxes"}= I18n.js('field_types.checkboxes')
+ %a.btn.btn-small{"data-backbone-add-field" => "radio"}= I18n.js('field_types.radio')
+ %a.btn.btn-small{"data-backbone-add-field" => "dropdown"}= I18n.js('field_types.dropdown')
+ %a.btn.btn-small{"data-backbone-add-field" => "price"}= I18n.js('field_types.price')
+ %a.btn.btn-small{"data-backbone-add-field" => "number"}= I18n.js('field_types.number')
+ %a.btn.btn-small{"data-backbone-add-field" => "date"}= I18n.js('field_types.date')
+ %a.btn.btn-small{"data-backbone-add-field" => "time"}= I18n.js('field_types.time')
+ %a.btn.btn-small{"data-backbone-add-field" => "website"}= I18n.js('field_types.website')
+ %a.btn.btn-small{"data-backbone-add-field" => "file"}= I18n.js('field_types.file')
.tab-pane#editField
#edit-response-field-wrapper
@@ -29,26 +29,26 @@
#form-options-wrapper
.form-actions
- %button.btn.btn-success{"data-backbone-save-form" => "true", "data-loading-text" => "All Changes Saved"} Save Form
+ %button.btn.btn-success{"data-backbone-save-form" => "true", "data-loading-text" => I18n.js('all_changes_saved')}
+ = I18n.js('save_form')
%p
- %a.smaller{"href" => "/projects/#{@id}/response_fields/use_template"} Import response fields from template
+ %a.smaller{"href" => "/projects/#{@id}/response_fields/use_template"}= I18n.js('response_field.import')
%p
- %a.smaller{"data-toggle" => "showhide", "data-target" => "#form-template-form"} Save response fields as a template
+ %a.smaller{"data-toggle" => "showhide", "data-target" => "#form-template-form"}= I18n.js('response_field.save')
%form#form-template-form.hide{"action" => "/form_templates", "method" => "post"}
%input{"type" => "hidden", "name" => "project_id", "value" => @id}
- %input{"type" => "text", "name" => "name", "placeholder" => "Name for this template"}
- %button.btn.btn-inverse Save
+ %input{"type" => "text", "name" => "name", "placeholder" => I18n.js('response_field.new_name')}
+ %button.btn.btn-inverse= I18n.js('save')
.span7.bid-form-span
- %h4 Bid Form
+ %h4= I18n.js('bid_form')
%span.help-block{"data-rv-text" => "project.form_description"}
- #no-response-fields
- No response fields yet. Why don't you add one?
+ #no-response-fields= I18n.js('response_field.none')
#response-fields
#loading-indicator
%i.icon-refresh.icon-spin
- Loading...
+ = I18n.js('loading')
@@ -1,3 +1,3 @@
.subtemplate-wrapper.well{"data-backbone-cid" => @cid}
.actions-wrapper
- %button.btn.btn-mini.remove-field-button Remove Field
+ %button.btn.btn-mini.remove-field-button= I18n.js('response_field.remove_field')
View
@@ -60,7 +60,5 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
-
- config.assets.initialize_on_precompile = false
end
end
View
@@ -0,0 +1,25 @@
+# Split context in several files.
+# By default only one file with all translations is exported and
+# no configuration is required. Your settings for asset pipeline
+# are automatically recognized.
+#
+# If you want to split translations into several files or specify
+# locale contexts that will be exported, just use this file to do
+# so.
+#
+# If you're going to use the Rails 3.1 asset pipeline, change
+# the following configuration to something like this:
+#
+# translations:
+# - file: "app/assets/javascripts/i18n/translations.js"
+#
+# If you're running an old version, you can use something
+# like this:
+#
+# translations:
+# - file: "public/javascripts/translations.js"
+# only: "*"
+#
+translations:
+ - file: 'public/javascripts/en.js'
+ only: ["en.js.*"]
@@ -0,0 +1,61 @@
+en:
+ js:
+ save: "Save"
+ saving: "Saving..."
+ loading: "Loading..."
+ characters: characters
+ editing: "Editing"
+ remove: "Remove"
+ save_form: Save Form
+ all_changes_saved: All Changes Saved
+ bid_form: Bid Form
+
+ response_field:
+ description: description
+ integer_only: integer only
+ key_field: key field
+ label: label
+ min: min
+ max: max
+ min_length: min length
+ max_length: max_length
+ required: required
+ size: size
+ small: small
+ medium: medium
+ large: large
+ units: units
+ add_option: Add option
+ include_blank: Include blank option
+ is_default: Default?
+ value: Value
+ no_default_selected: No default selected
+ remove_field: Remove field
+ form_description: Form Description
+ form_confirmation_message: Form Confirmation Message
+ no_confirmation_message: "If no confirmation message is set, we'll just redirect the vendor to a copy of their bid."
+
+ add_new_field: Add New Field
+ edit_field: Edit Field
+ form_options: Form Options
+
+ import: Import response fields from template
+ save: Save response fields as a template
+ new_name: "Name for this template"
+
+ none: "No response fields yet. Why don't you add one?"
+
+ field_types:
+ text: text
+ paragraph: paragraph
+ checkboxes: checkboxes
+ radio: radio
+ dropdown: dropdown
+ price: price
+ number: number
+ date: date
+ time: time
+ website: website
+ file: file
+
+
@@ -213,7 +213,7 @@ en:
new:
header: "New Project"
instructions: "First, tell us some basic info about your project."
- next_html: "Next "
+ next_html: "Next &rarr;"
show:
you_are_collaborator:
@@ -323,3 +323,4 @@ en:
%{results}
-- %{site_name}
+

0 comments on commit db1f661

Please sign in to comment.