|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
Upgrade path to Globalize2Hi all
I'm a satisfied user of Globalize (version 1) but eager to upgrade to Rails 2.2. What's the upgrade path from the old Globalize to Globalize2? I have many view translations I wish to preserve. Thanks for any help |
|
|
Re: Upgrade path to Globalize2Hi Joost,
there's none. Globalize2 uses the Rails I18n API which is not compatible with Globalize. That's the price we had to pay for "doing the right thing". That said, one could imagine a tool that helps converting existing views. If you're interested in trying something like that, you might want to register to the rails-i18n Google group and ask for ideas or help. On 23.11.2008, at 00:10, joost wrote: > Hi all > > I'm a satisfied user of Globalize (version 1) but eager to upgrade > to Rails 2.2. > > What's the upgrade path from the old Globalize to Globalize2? I have > many view translations I wish to preserve. > > Thanks for any help |
|
|
Re: Upgrade path to Globalize2Ouch, this is what I feared. That's going to hurt.
Sorry for the noob question, but is it correct that Globalize2’s Static backend works with yaml/rb files only, and does not store translations in the database? In which case I would have to unload the viewtranslations from the db and store them in .yml files? Since I don't need any model translations at this point (and I can live with simple pluralization) would it be correct to assume I can just use the built-in I18n module instead? Thanks again Op 23 nov 2008, om 00:55 heeft Sven Fuchs het volgende geschreven: > Hi Joost, > > there's none. > > Globalize2 uses the Rails I18n API which is not compatible with > Globalize. > > That's the price we had to pay for "doing the right thing". > > That said, one could imagine a tool that helps converting existing > views. If you're interested in trying something like that, you might > want to register to the rails-i18n Google group and ask for ideas or > help. > > > On 23.11.2008, at 00:10, joost wrote: > >> Hi all >> >> I'm a satisfied user of Globalize (version 1) but eager to upgrade >> to Rails 2.2. >> >> What's the upgrade path from the old Globalize to Globalize2? I >> have many view translations I wish to preserve. >> >> Thanks for any help > |
|
|
Re: Upgrade path to Globalize2On 23.11.2008, at 01:11, joost wrote:
> Ouch, this is what I feared. That's going to hurt. Yeah, sorry for that :( There was no way around it. > Sorry for the noob question, but is it correct that Globalize2’s > Static backend works with yaml/rb files only, and does not store > translations in the database? Yes. > In which case I would have to unload the viewtranslations from the > db and store them in .yml files? Unless you do or find a db backend for that, yes. There's something on GitHub: http://github.com/yar/i18n_db and http://github.com/yar/i18n_db_admin I can't tell about the status or quality though. > Since I don't need any model translations at this point (and I can > live with simple pluralization) would it be correct to assume I can > just use the built-in I18n module instead? Most probably, yes. What locales do you need to support? Anything fancy? > > > Thanks again > > Op 23 nov 2008, om 00:55 heeft Sven Fuchs het volgende geschreven: > >> Hi Joost, >> >> there's none. >> >> Globalize2 uses the Rails I18n API which is not compatible with >> Globalize. >> >> That's the price we had to pay for "doing the right thing". >> >> That said, one could imagine a tool that helps converting existing >> views. If you're interested in trying something like that, you >> might want to register to the rails-i18n Google group and ask for >> ideas or help. >> >> >> On 23.11.2008, at 00:10, joost wrote: >> >>> Hi all >>> >>> I'm a satisfied user of Globalize (version 1) but eager to upgrade >>> to Rails 2.2. >>> >>> What's the upgrade path from the old Globalize to Globalize2? I >>> have many view translations I wish to preserve. >>> >>> Thanks for any help >> > |
|
|
Re: Upgrade path to Globalize2I have a compatibility layer which will allow you to access your view
translations from Rails 2.2, with the same syntax as in Globalize 1. I will post it on Monday evening when I return back home. 23 nov 2008 kl. 00.11 skrev joost <joost@...>: > Ouch, this is what I feared. That's going to hurt. > > Sorry for the noob question, but is it correct that Globalize2’s Sta > tic backend works with yaml/rb files only, and does not store transl > ations in the database? In which case I would have to unload the vie > wtranslations from the db and store them in .yml files? > > Since I don't need any model translations at this point (and I can > live with simple pluralization) would it be correct to assume I can > just use the built-in I18n module instead? > > > Thanks again > > Op 23 nov 2008, om 00:55 heeft Sven Fuchs het volgende geschreven: > >> Hi Joost, >> >> there's none. >> >> Globalize2 uses the Rails I18n API which is not compatible with >> Globalize. >> >> That's the price we had to pay for "doing the right thing". >> >> That said, one could imagine a tool that helps converting existing >> views. If you're interested in trying something like that, you >> might want to register to the rails-i18n Google group and ask for >> ideas or help. >> >> >> On 23.11.2008, at 00:10, joost wrote: >> >>> Hi all >>> >>> I'm a satisfied user of Globalize (version 1) but eager to upgrade >>> to Rails 2.2. >>> >>> What's the upgrade path from the old Globalize to Globalize2? I >>> have many view translations I wish to preserve. >>> >>> Thanks for any help >> > |
|
|
Re: Upgrade path to Globalize2Op 23 nov 2008, om 01:18 heeft Sven Fuchs het volgende geschreven: > On 23.11.2008, at 01:11, joost wrote: >> Ouch, this is what I feared. That's going to hurt. > > Yeah, sorry for that :( > > There was no way around it. It's okay, you can't make an omelet without breaking some eggs. And the (your) work on I18n is very solid. >> In which case I would have to unload the viewtranslations from the >> db and store them in .yml files? > Unless you do or find a db backend for that, yes. > > There's something on GitHub: http://github.com/yar/i18n_db and http://github.com/yar/i18n_db_admin These solutions sound like they are better suited for me, with just View translations and a need to keep the strings in the db. I will check them out and ping the owners. Last activity is from October, so they should be fairly active. Thanks for the links! >> Since I don't need any model translations at this point (and I can >> live with simple pluralization) would it be correct to assume I can >> just use the built-in I18n module instead? > > Most probably, yes. What locales do you need to support? Anything > fancy? Just languages in Latin alphabets: es, en, fr, it, nl. So I think I am good. Thanks! |
|
|
Re: Upgrade path to Globalize2Op 23 nov 2008, om 02:44 heeft Peter Bengtson het volgende geschreven: > I have a compatibility layer which will allow you to access your > view translations from Rails 2.2, with the same syntax as in > Globalize 1. I will post it on Monday evening when I return back home. That sounds very promising! |
|
|
Re: Upgrade path to Globalize2On 23.11.2008, at 13:00, joost wrote:
> Just languages in Latin alphabets: es, en, fr, it, nl. So I think I > am good. Yeah, that should work with rails i18n then. As long as you don't expect "ijsbeer" to title-ize to "IJsbeer" ;) |
|
|
Re: Upgrade path to Globalize2Op 23 nov 2008, om 13:33 heeft Sven Fuchs het volgende geschreven: >> Just languages in Latin alphabets: es, en, fr, it, nl. So I think I >> am good. > > Yeah, that should work with rails i18n then. > > As long as you don't expect "ijsbeer" to title-ize to "IJsbeer" ;) Global warming will take care of those ;-( |
|
|
Re: Upgrade path to Globalize2>>In which case I would have to unload the viewtranslations from the
>>db and store them in .yml files? > >Unless you do or find a db backend for that, yes. > >There's something on GitHub: http://github.com/yar/i18n_db and >http://github.com/yar/i18n_db_admin I'm just looking at Rails 2.2 -- but I use mainly Globalize for model-translations. The projects linked above do not do model translations. Does anybody know of any internationalization work to make model translations work in Rails >= 2.2? |
|
|
Re: Upgrade path to Globalize2Here's the Globalize 1 replacement. It allows you to access your old
view translations using the same syntax as in Globalize 1. Just pop it in as an initializer. Update as accordingly for your default language. ################################################################ # Re-implement the Globalize basic classes # ################################################################ class GlobalizeTranslation < ActiveRecord::Base belongs_to :language, :class_name => 'GlobalizeLanguage', :foreign_key => :language_id end class ViewTranslation < GlobalizeTranslation end class ModelTranslation < GlobalizeTranslation end class GlobalizeLanguage < ActiveRecord::Base has_many :translations, :class_name => 'GlobalizeTranslation', :foreign_key => :language_id has_many :user_translations, :class_name => 'GlobalizeTranslation', :foreign_key => :language_id, :conditions => { :built_in => nil } end ################################################################ # Define a new backend, inheriting from the default Simple one # ################################################################ module I18n class << self protected # Merges the given locale, key and scope into a single array of keys. # Splits keys that contain dots into multiple keys, but only if the # key is not a built-in translation. # Makes sure all keys are Symbols. def normalize_translation_keys(locale, key, scope) keys = [locale] + Array(scope) + [key] keys = keys.map{|k| k.to_s.split(/\./) } result = keys.flatten.map{|k| k.to_sym} if ! [:date, :time, :support, :number, :datetime, :activerecord].include? (result[1]) result = [result[0], :sql, (Array(scope).collect{|k| k.to_sym}), key.to_sym].flatten end result end end module Backend class GlobalizeErsatz < Simple protected def init_translations load_translations(*I18n.load_path) load_globalize_translations @initialized = true end def load_globalize_translations translations.keys.each do |locale| lang = GlobalizeLanguage.find_by_iso_639_1(locale.to_s[0..1]) lang.user_translations.each do |tr| next unless tr.is_a?(ViewTranslation) next if tr.tr_key.blank? next unless tr.text if !tr.namespace.blank? data = { :sql => { tr.namespace.to_sym => { tr.tr_key.to_sym => tr.text } } } else data = { :sql => { tr.tr_key.to_sym => tr.text } } end merge_translations(locale, data) end end end end end end I18n.backend = I18n::Backend::GlobalizeErsatz.new ################################################################ # It takes the same .rb and .yml files as Simple, for the very # # basic translations. # ################################################################ LOCALES_DIRECTORY = File.join(RAILS_ROOT, 'config', 'locales') LOCALE_FILES = Dir[ File.join(LOCALES_DIRECTORY, '*.{rb,yml}') ] LOCALES = LOCALE_FILES.collect do |locale_file| File.basename(File.basename(locale_file, ".rb"), ".yml") end.uniq.sort I18n.load_path += LOCALE_FILES ################################################################ # Our base language is Swedish # ################################################################ I18n.default_locale = "sv-SE" ################################################################ # Re-implement the classical Globalize string extensions # ################################################################ class String def translate I18n.t self, :default => self end def t translate end def tn(namespace) I18n.t self, :scope => namespace, :default => self end def /(val) if sub!('%d', '{{count}}') I18n.t self, :count => val, :default => self elsif sub!('%s', '{{s}}') I18n.t self, :s => val, :default => self else translate end end end |
| Free embeddable forum powered by Nabble | Forum Help |