Class: TranslationsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- TranslationsController
- Defined in:
- lib/controllers/translations_controller.rb
Instance Method Summary collapse
-
#asset_translations ⇒ Object
GET /asset_translations GET /asset_translations.xml.
-
#create ⇒ Object
POST /translations POST /translations.xml.
-
#destroy ⇒ Object
DELETE /translations/1 DELETE /translations/1.xml.
-
#edit ⇒ Object
GET /translations/1/edit.
-
#index ⇒ Object
GET /translations GET /translations.xml.
-
#new ⇒ Object
GET /translations/new GET /translations/new.xml.
-
#show ⇒ Object
GET /translations/1 GET /translations/1.xml.
-
#translations ⇒ Object
GET /translations GET /translations.xml.
-
#update ⇒ Object
PUT /translations/1 PUT /translations/1.xml.
Instance Method Details
#asset_translations ⇒ Object
GET /asset_translations GET /asset_translations.xml
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/controllers/translations_controller.rb', line 39 def asset_translations @locale ||= Locale.default_locale @translation_option = TranslationOption.find(params[:translation_option]) @asset_translations = I18n.asset_translations @untranslated_assets = I18n.untranslated_assets(@locale.code) @percentage_translated = (((@asset_translations.size - @untranslated_assets.size).to_f / @asset_translations.size.to_f * 100).round) rescue 0 if @translation_option == TranslationOption.translated @asset_translations = @asset_translations.reject{|e| @untranslated_assets.include?(e)} else @asset_translations = @untranslated_assets end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @untranslated_assets } end end |
#create ⇒ Object
POST /translations POST /translations.xml
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/controllers/translations_controller.rb', line 88 def create @translation = @locale.translations.build(params[:translation]) respond_to do |format| if @translation.save flash[:notice] = 'Translation was successfully created.' format.html { redirect_to locale_translation_path(@locale, @translation) } format.xml { render :xml => @translation, :status => :created, :location => @translation } else format.html { render :action => "new" } format.xml { render :xml => @translation.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /translations/1 DELETE /translations/1.xml
126 127 128 129 130 131 132 133 134 |
# File 'lib/controllers/translations_controller.rb', line 126 def destroy @translation = @locale.translations.find(params[:id]) @translation.destroy respond_to do |format| format.html { redirect_to(locale_translations_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /translations/1/edit
82 83 84 |
# File 'lib/controllers/translations_controller.rb', line 82 def edit @translation = @locale.translations.find(params[:id]) end |
#index ⇒ Object
GET /translations GET /translations.xml
10 11 12 13 14 15 16 17 |
# File 'lib/controllers/translations_controller.rb', line 10 def index @translations = @locale.translations.find(:all, :order => "raw_key, pluralization_index") respond_to do |format| format.html # index.html.erb format.xml { render :xml => @translations } end end |
#new ⇒ Object
GET /translations/new GET /translations/new.xml
72 73 74 75 76 77 78 79 |
# File 'lib/controllers/translations_controller.rb', line 72 def new @translation = Translation.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @translation } end end |
#show ⇒ Object
GET /translations/1 GET /translations/1.xml
61 62 63 64 65 66 67 68 |
# File 'lib/controllers/translations_controller.rb', line 61 def show @translation = @locale.translations.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @translation } end end |
#translations ⇒ Object
GET /translations GET /translations.xml
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/controllers/translations_controller.rb', line 21 def translations @locale ||= Locale.default_locale @translation_option = TranslationOption.find(params[:translation_option]) if @translation_option == TranslationOption.translated @translations = @locale.translations.translated else @translations = @locale.translations.untranslated end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @translations } end end |
#update ⇒ Object
PUT /translations/1 PUT /translations/1.xml
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/controllers/translations_controller.rb', line 105 def update @translation = @locale.translations.find(params[:id]) @first_time_translating = @translation.value.nil? respond_to do |format| if @translation.update_attributes(params[:translation]) format.html do flash[:notice] = 'Translation was successfully updated.' redirect_to locale_translation_path(@locale, @translation) end format.xml { head :ok } format.js {} else format.html { render :action => "edit" } format.xml { render :xml => @translation.errors, :status => :unprocessable_entity } end end end |