joshmh / globalize2

The second incarnation of Globalize for Rails
http://www.globalize-rails.org/
MIT License
364 stars 57 forks source link

fallbacks method not there?! #25

Open triaxman opened 14 years ago

triaxman commented 14 years ago

Hello,

i am quite new to Globalize2. I've been doing my translations until now using the integrated i18n rails stuff. So i used the usual language files. Now i badly need to do all stuff in a database. I have installed the joshmh/globalize2 plugin and also managed to get some results.

The problem comes when using 'fallbacks' method. Is fails with an error: /config/initializers/globalize.rb:1: undefined method fallbacks' for I18n:Module (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload_without_new_constant_marking' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load'.....etc.

What I have and works withour problems, you can see here: post.rb model: class Post < ActiveRecord::Base translates :title, :text end

post controller: class PostsController < ApplicationController def index @posts = Post.find(:all) end end

index.html.erb: <%- @posts.each do |post| %> Title: <%= post.title %>
Text: <%= post.text %>

<%- end %>

As soon as I want to set the fallsbacks , <% I18n.fallbacks[:de] %> it crashes with the above error.

So, why do I get the translations correctly from the database (which tells me the plugin is working somehow), but the method does not exist? It's quite strange. :-( Can somebody help me out with this?

Regards, Chris

fillman commented 14 years ago

Damn! I also wonder how to enable I18n Fallbacks. Please someone help us out!

triaxman commented 14 years ago

i delete the joshmh/globalize2 and took the OLD one from fd/globalize2. guess what! whit this one I don't get anny error! the only thing is, that the specified fallback language won't get retrieved, so it's always falling back on english even if I said german. anyways, can someone explain, how come that the NEWER joshmh/globalize2 ain't working? :-(

triaxman commented 14 years ago

i gave it a new shot: sudo script/plugin install git://github.com/hukl/globalize2

ain't working either: ActionView::TemplateError (undefined method `fallbacks' for I18n:Module) on line #1 of app/views/posts/index.html.erb: 1: <%- I18n.fallbacks[:de] %>

triaxman commented 14 years ago

So, I wanna share my latest bad news with you. I've been trying some older versions of the Globalize2 plugin and they seem to have no problem with the fallbacks method. However, they all have some severe problems with form_for, hash building and some other very strange stuff which makes my current apllication break apart. Sadly.

Nobody has a statement what can be done here? How can I make following to work? I18n.fallbacks.inspect ---> undefined method fallbacks I18n:Module @posts.each do |post| post.title.fallback? ---> undefined method fallback?' for nil:NilClass post.title.locale.to ---> undefined methodlocale' for nil:NilClass end Don't wanna repeat myself, but those method calls DO work previous to 0.2.0. :-) So, what am I doing wrong?

@fillman: Your Globalize2 version is also a 0.1.1 version which actually work with fallback but crashes on form_for and other stuff.

triaxman commented 14 years ago

A sample of what older versions (i.e.0.1.1) prior 0.2.0 produce:

ArgumentError in Pages#new Showing app/views/pages/_form.html.erb where line #6 raised: "odd number of arguments for Hash" Extracted source (around line #6): 5: <%- form_for @page do |f| %> 6: <%= f.error_messages %>

etc.

As soon as I remove the plugin, restart the server, all is fine. So I guess the plugin interferres with Rails so deep, that it actually does its purpose for globalizing but also mixes up some other stuff. :-/

triaxman commented 14 years ago

I wanna quote Sven Fuchs: "Big refactoring towards version 0.2.0. Stripping off all features that have been duplicated in I18n. Only model translations related features will remain in Globalize2." Ok, no problem with that. But can you tell us what's the alternative for the "fallback?" method ?? Otherwise 0.2.0 is a total downgrade. So where is the point?

ncri commented 14 years ago

Well, i am also pulling my hair out about this. Globalize2 is great, but its documentation is more than poor. It seems you need to install the I18n plugin to get the locale fallbacks back. See here: http://stackoverflow.com/questions/2147179/how-to-enable-fallback-in-i18n-with-globalize2

This is quite confusing. I wish there would be some overview page clearly explaining when to use what and what for (Globalize2, I18n Gem,...). And of cause a good documentation of G2.

stuffmc commented 14 years ago

Anything new on this?

fillman commented 14 years ago

what u wanna know?

stuffmc commented 14 years ago

Actually I can't make Globalize2 work in my App, and in the Sample App, it's failing on fallbacks. A sample app failing it's kind of uncool :)

ncri commented 14 years ago

Any body got fallbacks working? See also this post: http://github.com/svenfuchs/i18n/issues/#issue/11

bernardeli commented 14 years ago

just take a look here: http://stackoverflow.com/questions/2147179/how-to-enable-fallback-in-i18n-with-globalize2

it worked smoothly for me.