107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'app/controllers/i18n/edit/edit_controller.rb', line 107
def update
key = params[:key]
text = params[:text]
old_text = params[:old_text]
path = KeyLocations[key.to_sym]
if text.gsub(/\s/, '').blank?
render plain: "Erasing the entire locale text isn't allowed.", layout: false, status: 202
return
end
if path.nil?
render plain: "No locale file in your project for #{key}, your edit was not written.", layout: false, status: 201
return
end
return if !write_file(path, key, old_text, text)
message = "Wrote #{path} for #{key}"
logger.info(message)
render plain: message, layout: false, status: 200
end
|