Parse errors in accentuated strings after Globalizing

After installing Globalize and adding the following lines to the files:

environment.rb at the end:

include Globalize
Locale.set_base_language ‘es-ES’
LOCALES = {‘es’ => ‘es-ES’,
‘en’ => ‘en-EN’}.freeze

routes.rb at the begining:

map.connect ‘:locale/:controller/:action/:id’


before_filter :set_locale
def set_locale
Locale.set params[:locale]
rescue ArgumentError
redirect_to params.merge( ‘locale’ => Locale.base_language.code )

some accentuated strings now give me a lot of problems that they were
not giving before the Globalize installation.I have a controller in

@options << option("Investigación","investigacion","index")

throws the following error:
./script/…/config/…/app/controllers/menu_controller.rb:14: parse
error, unexpected tIDENTIFIER, expecting ‘)’
@options << option(“Investigaci�n”,“investigacion”,“index”)
This can be solved changing “Investigación” with “Investigacion”. But
I’ve read that the base language can be the one of your choice. Because
all the basic content of the web is spanish I decided to set the base
language to spanish.

I’m worried because I thought that the web that I’m trying to
internationalize (to english) should work perfectly in spanish as it was

If someone had this problem and knows where the problem is, I would
appreciate a little help with the question.

Best regards

not sure, but it could be related to the fact that ruby doesn’t natively
support charsets in the strings.

Usually you can fix this kind of problems by using jcode and setting
KCODE to UTF-8 at environment.rb by adding these two lines of code

|$KCODE = ‘u’
require ‘jcode’

After you do this, the lenght of strings and so on works on multichar
strings. A quick search in google by jcode and rails should put you on
the right track for these.

Not sure if that’s your problem, but for sure it’s a good practice when
dealing with non-english charsets

saludos :wink:


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs