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’
Locale.set(‘es-ES’)
LOCALES = {‘es’ => ‘es-ES’,
‘en’ => ‘en-EN’}.freeze

routes.rb at the begining:

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

application.rb:

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

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

@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
before.

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:

javier

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