diff options
Diffstat (limited to 'lib/redmine/i18n.rb')
-rw-r--r-- | lib/redmine/i18n.rb | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index a9cd1dd0d..0b31cb235 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -65,9 +65,9 @@ module Redmine end # Localizes the given args with user's language - def lu(user, *args) + def lu(user, *) lang = user.try(:language).presence || Setting.default_language - ll(lang, *args) + ll(lang, *) end def format_date(date) @@ -94,8 +94,9 @@ module Redmine minutes = (hours * 60).round if Setting.timespan_format == 'minutes' - h, m = minutes.divmod(60) - "%d:%02d" % [h, m] + h, m = minutes.abs.divmod(60) + sign = minutes.negative? ? '-' : '' + "%s%d:%02d" % [sign, h, m] else number_with_delimiter(sprintf('%.2f', minutes.fdiv(60)), delimiter: nil) end @@ -110,7 +111,7 @@ module Redmine # will clash with the dot separator. def normalize_float(value) separator = ::I18n.t('number.format.separator') - value.gsub(/[#{separator}]/, separator => '.') + value.to_s.gsub(/[#{separator}]/, separator => '.') end def day_name(day) @@ -151,7 +152,7 @@ module Redmine languages_options :cache => false end end - options.map {|name, lang| [name.force_encoding("UTF-8"), lang.force_encoding("UTF-8")]} + options.map {|name, lang| [(+name).force_encoding("UTF-8"), (+lang).force_encoding("UTF-8")]} end def find_language(lang) @@ -172,24 +173,5 @@ module Redmine def current_language ::I18n.locale end - - # Custom backend based on I18n::Backend::Simple with the following changes: - # * available_locales are determined by looking at translation file names - class Backend < ::I18n::Backend::Simple - module Implementation - # Get available locales from the translations filenames - def available_locales - @available_locales ||= begin - redmine_locales = Dir[Rails.root / 'config' / 'locales' / '*.yml'].map { |f| File.basename(f, '.yml').to_sym } - super & redmine_locales - end - end - end - - # Adds custom pluralization rules - include ::I18n::Backend::Pluralization - # Adds fallback to default locale for untranslated strings - include ::I18n::Backend::Fallbacks - end end end |