diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-08-14 08:20:32 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-08-14 08:20:32 +0000 |
commit | 035edd39c422c9434147a1b0ac457cb9383c9b5b (patch) | |
tree | 4b25e158e04068c535e828c04f336c769ac9db9c /lib/redmine | |
parent | 763d5dddde2c7dda03fe529c9dfe0d553669c277 (diff) | |
download | redmine-035edd39c422c9434147a1b0ac457cb9383c9b5b.tar.gz redmine-035edd39c422c9434147a1b0ac457cb9383c9b5b.zip |
Import issues from CSV file (#950).
git-svn-id: http://svn.redmine.org/redmine/trunk@14493 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/i18n.rb | 12 | ||||
-rw-r--r-- | lib/redmine/utils.rb | 21 |
2 files changed, 31 insertions, 2 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index 0091186f4..b028e3e30 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -52,8 +52,16 @@ module Redmine "%.2f h" % hours.to_f end - def ll(lang, str, value=nil) - ::I18n.t(str.to_s, :value => value, :locale => lang.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" }) + def ll(lang, str, arg=nil) + options = arg.is_a?(Hash) ? arg : {:value => arg} + locale = lang.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" } + ::I18n.t(str.to_s, options.merge(:locale => locale)) + end + + # Localizes the given args with user's language + def lu(user, *args) + lang = user.try(:language) || Setting.default_language + ll(lang, *args) end def format_date(date) diff --git a/lib/redmine/utils.rb b/lib/redmine/utils.rb index 56350052f..ed27d7e84 100644 --- a/lib/redmine/utils.rb +++ b/lib/redmine/utils.rb @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +require 'fileutils' + module Redmine module Utils class << self @@ -40,6 +42,25 @@ module Redmine def random_hex(n) SecureRandom.hex(n) end + + def save_upload(upload, path) + directory = File.dirname(path) + unless File.exists?(directory) + FileUtils.mkdir_p directory + end + File.open(path, "wb") do |f| + if upload.respond_to?(:read) + buffer = "" + while (buffer = upload.read(8192)) + f.write(buffer) + yield buffer if block_given? + end + else + f.write(upload) + yield upload if block_given? + end + end + end end module Shell |