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/
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
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. [email protected] 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/>
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/.>
_______________________________________________> Railsi18n-discussion
mailing list> [email protected]>
http://rubyforge.org/mailman/listinfo/railsi18n-discussion>
I’m currently stuck somewhere else. Using the code from the Rails
Recipes book 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
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. [email protected] wrote:> I’m
currently stuck somewhere else. Using the code from the Rails> Recipes
book 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/.>
_______________________________________________> Railsi18n-discussion
mailing list> [email protected]>
http://rubyforge.org/mailman/listinfo/railsi18n-discussion
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.