# Globalize for Rails 1.1 setup (MySQL)

**URL:** <https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668>\
**Category:** Rails I18n\
**Created:** [May 16, 2006, 5:45pm UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668 "2006-05-16T17:45:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [May 16, 2006, 5:45pm UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668/1 "2006-05-16T17:45:50Z")

</div>

Before I check if I can use Globalize with Oracle I’m trying a test on  
MySQL first. I’m using Rails 1.1.2. with Ruby 1.8.2 (Linux).

> ruby script/plugin install [http://svn.globalize-rails.org/svn/globalize/globalize/branches/for-1.1/](http://svn.globalize-rails.org/svn/globalize/globalize/branches/for-1.1/)  
> cd vendor/plugins/  
> mv for-1.1/ globalize  
> rake globalize:setup

Up to that poiint everything seems fine. Globalize\_countries /  
\_languages / \_translations have been created and populated.

But when I run

> rake test\_plugins

I get this

[…]  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/mysql\_adapter.rb:331:in  
`real\_connect’: Can’t connect to local MySQL server through socket  
‘/var/lib/mysql/mysql.sock’ (2) (Mysql::Error)  
[…]

Am I on the right track or did I do something wrong?  
Am I using the correct URL?  
Do I have to “mv for-1.1/ globalize”?  
Did anyone manage to set up Globalize with Rails 1.1 (and MySQL)?

TIA! - Bernd

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [May 16, 2006, 9:09pm UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668/2 "2006-05-16T21:09:11Z")

</div>

Are you sure that mysql socket exists? It’s also a good idea to  
renamefor-1.1 to globalize, as you mentioned, but I don’t think  
that’scausing the problem.  
Josh  
On 5/16/06, Martin Bernd S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\>  
Before I check if I can use Globalize with Oracle I’m trying a test on\>  
MySQL first. I’m using Rails 1.1.2. with Ruby 1.8.2 (Linux).\>\> \> ruby  
script/plugin install  
[http://svn.globalize-rails.org/svn/globalize/globalize/branches/for-1.1/](http://svn.globalize-rails.org/svn/globalize/globalize/branches/for-1.1/)\>

> cd vendor/plugins/\> \> mv for-1.1/ globalize\> \> rake globalize:setup\>\>  
> Up to that poiint everything seems fine. Globalize\_countries /\>  
> \_languages / \_translations have been created and populated.\>\> But when I  
> run\>\> \> rake test\_plugins\>\> I get this\>\> […]\>  
> /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active\_record/connection\_adapters/mysql\_adapter.rb:331:in\>  
> `real\_connect’: Can’t connect to local MySQL server through socket\>  
> ‘/var/lib/mysql/mysql.sock’ (2) (Mysql::Error)\> […]\>\> Am I on the  
> right track or did I do something wrong?\> Am I using the correct URL?\>  
> Do I have to “mv for-1.1/ globalize”?\> Did anyone manage to set up  
> Globalize with Rails 1.1 (and MySQL!  
> )?\>\> TIA! - Bernd\>\>\> → Posted via [http://www.ruby-forum.com/.](http://www.ruby-forum.com/.)\>  
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\> Railsi18n-discussion  
> mailing list\> removed\_email\_address@domain.invalid\>  
> [http://rubyforge.org/mailman/listinfo/railsi18n-discussion](http://rubyforge.org/mailman/listinfo/railsi18n-discussion)\>

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [May 19, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668/3 "2006-05-19T18:23:59Z")

</div>

I’m currently stuck somewhere else. Using the code from the Rails  
Recipes book [http://media.pragprog.com/titles/fr\_rr/Localize.pdf](http://media.pragprog.com/titles/fr_rr/Localize.pdf), I’m  
getting a

Globalize::WrongLanguageError.

This is the current code:

conf/environment.rb:

require File.join(File.dirname( **FILE** ), ‘boot’)

Rails::Initializer.run do |config|  
end

# $KCODE = ‘u’

# require ‘jcode’

include Globalize  
Locale.set\_base\_language ‘en-US’  
Locale.set ‘en-US’

app/models/product.rb:

class Product \< ActiveRecord::Base  
translates :name, :description  
end

globalize\_controller.rb:

def init\_data  
logger.debug(“INIT DATA!!!”)  
Locale.set ‘en-US’  
prod = Product.create(:name =\> “Yemenese Coffee” ,  
:description =\> “Coffee from the South of Yemen”  
)  
Locale.set ‘de-DE’  
prod.name = “SÃ¼djemenitischer Kaffee”  
prod.description = “Kaffee aus SÃ¼djemen”  
prod.save  
end

The Locale.set ‘de-DE’ causes the trouble (I tried other locales as  
well).

BTW - the rfc\_3066 columns in globalize\_languages are all NULL.

Thanks for any help! - Bernd

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [May 19, 2006, 9:45pm UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668/4 "2006-05-19T21:45:37Z")

</div>

It’s weird that that made it into the book, it shouldn’t work.  
Locale.set ‘en-US’ prod = Product.create(:name =\> “Yemenese Coffee”  
, :description =\> “Coffee from the South of  
Yemen” ) Locale.set ‘de-DE’ prod.name = “SÃ¼djemenitischer Kaffee”  
prod.description = “Kaffee aus SÃ¼djemen” prod.save  
should be:  
Locale.set ‘en-US’ prod = Product.create(:name =\> “Yemenese Coffee”  
, :description =\> “Coffee from the South of  
Yemen” ) Locale.set ‘de-DE’ prod.reload # You need this  
prod.name = “SÃ¼djemenitischer Kaffee” prod.description = “Kaffee aus  
SÃ¼djemen” prod.save  
The reason you need the reload is that Globalize only loads  
thetranslation of the current language, so it doesn’t have the  
Germantranslation in this case. In a future version we might want  
toautomatically reload the translated object instead of throwing  
theexception.  
The rfc\_3066 column is meant primarily for user-defined  
dialects,although there are some common ones that should probably be  
there,like pt-BR.  
– Josh  
On 5/19/06, Martin Bernd S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\> I’m  
currently stuck somewhere else. Using the code from the Rails\> Recipes  
book [http://media.pragprog.com/titles/fr\_rr/Localize.pdf](http://media.pragprog.com/titles/fr_rr/Localize.pdf), I’m\> getting  
a\>\> Globalize::WrongLanguageError.\>\>\> This is the current code:\>\>\>  
conf/environment.rb:\>\> require File.join(File.dirname( **FILE** ),  
‘boot’)\>\> Rails::Initializer.run do |config|\> end\>\> # $KCODE = ‘u’\> #  
require ‘jcode’\>\> include Globalize\> Locale.set\_base\_language ‘en-US’\>  
Locale.set ‘en-US’\>\>\> app/models/product.rb:\>\> class Product \<  
ActiveRecord::Base\> translates :name, :description\> end\>\>\>  
globalize\_controller.rb:\>\> def init\_data\> logger.debug(“INIT  
DATA!!!”)\> Locale.set ‘en-US’\> prod = Product.create(:name =\>  
“Yemenese Coffee” ,\> :description =\> “Coffee  
from the South of Yemen”\> )\> Locale.set ‘de-DE’\> prod.name =  
“SÃ¼djemenitischer Kaffee”\> prod.description = “Kaffee aus SÃ¼djemen”\>  
prod.save\> end\>\>\> The Locale.set ‘de-DE’ causes the trouble (I tried  
other locales as\> well).\>\> BTW - the rfc\_3066 columns in  
globalize\_languages are all NULL.\>\> Thanks for any help! - Bernd\>\> →   
Posted via [http://www.ruby-forum.com/.](http://www.ruby-forum.com/.)\>  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\> Railsi18n-discussion  
mailing list\> removed\_email\_address@domain.invalid\>  
[http://rubyforge.org/mailman/listinfo/railsi18n-discussion](http://rubyforge.org/mailman/listinfo/railsi18n-discussion)

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [May 20, 2006, 5:58am UTC](https://www.ruby-forum.com/t/globalize-for-rails-1-1-setup-mysql/60668/5 "2006-05-20T05:58:59Z")

</div>

Joshua Harvey wrote:

> Locale.set ‘en-US’  
> prod = Product.create(:name =\> “Yemenese Coffee”,  
> :description =\> “Coffee from the South of Yemen”)  
> Locale.set ‘de-DE’  
> prod.reload # You need this  
> prod.name = “SÃ¼djemenitischer Kaffee”  
> prod.description = “Kaffee aus SÃ¼djemen”  
> prod.save
> 
> The reason you need the reload is that Globalize only loads  
> the translation of the current language, so it doesn’t have the  
> German translation in this case. In a future version we might want  
> to automatically reload the translated object instead of throwing  
> theexception.  
> The rfc\_3066 column is meant primarily for user-defined  
> dialects, although there are some common ones that should probably be  
> there,like pt-BR.  
> – Josh

Hi Josh,

thanks a lot! I’ll check again. This recipe if from the website and  
might have been fixed for the book already (or it was me who skipped the  
reload). I’ll contact the author about this.
