globalize2 icon indicating copy to clipboard operation
globalize2 copied to clipboard

fallbacks method not there?!

Open triaxman opened this issue 15 years ago • 12 comments

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

triaxman avatar Jan 26 '10 19:01 triaxman

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

fillman avatar Jan 27 '10 08:01 fillman

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 avatar Jan 30 '10 00:01 triaxman

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 avatar Jan 30 '10 00:01 triaxman

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 avatar Jan 31 '10 11:01 triaxman

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 avatar Jan 31 '10 12:01 triaxman

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?

triaxman avatar Feb 04 '10 22:02 triaxman

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.

ncri avatar Mar 05 '10 18:03 ncri

Anything new on this?

stuffmc avatar Apr 08 '10 13:04 stuffmc

what u wanna know?

fillman avatar Apr 08 '10 15:04 fillman

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 :)

stuffmc avatar Apr 08 '10 15:04 stuffmc

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

ncri avatar Apr 29 '10 06:04 ncri

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

it worked smoothly for me.

bernardeli avatar Jun 15 '10 15:06 bernardeli