Project

General

Profile

« Previous | Next » 

Revision 0c8e424e

Added by Marc Dequènes over 13 years ago

  • ID 0c8e424e9d4d008afd1198f01628d4bbfaccb972

[fix/evol] I18n: propagate context in order to late-translate back in this context, and cleanup

View differences:

lib/cyborghood/base/language.rb
end
def locale_from_prefs(preferred_locales)
return DEFAULT_LOCALE if preferred_locales.nil?
locale = @prefs_to_locale_cache[preferred_locales]
return locale if locale
......
end
def create_tm(message, parts, method = nil)
translated_message = (method.nil? ? message : self.send(method, message))
I18nMessage.new(message, parts, method)
I18nMessage.new(message, parts, self, method)
end
module_function :_, :n_, :s_, :ns_, :np_
......
class I18nMessage
include I18nTranslation
attr_reader :translated, :untranslated, :parts
attr_reader :untranslated, :parts
def initialize(untranslated, parts, method)
def initialize(untranslated, parts, context, method)
@untranslated = untranslated % parts
@parts = parts
@context = context
@method = method
@translated = nil
end
def to_s
self.send(@method, @untranslated) % parts
ch_i18n_msg_method, ch_i18n_msg_untranslated, ch_i18n_msg_parts = @method, @untranslated, @parts
@context.instance_eval do
send(ch_i18n_msg_method, ch_i18n_msg_untranslated) % ch_i18n_msg_parts
end
end
def translate(preferred_locales)

Also available in: Unified diff