Multilanguage problem, need help


#1

hey,

i use
http://mir.aculo.us/articles/2005/10/03/ruby-on-rails-i18n-revisited

then i have nl_BE.rb, de_DE.rb, en_US.rb as translation files.

this works all fine when i have normal characters, but i have one
problem
when i have wierd characters like é à è (mostly in french), then i get
japanese
charachters on my site

i use utf8 for my database and i set this for each def in my
controllers, all
characters are set in my database as they are,
ex é => é (not some wierd stuff), à => Ã

@headers[“Content-Type”] = “text/html; harset=utf-8”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end

but these translations files are not in the db huh, what do i need to
do???


#2

I had the same problem with Greek and solved it by saving the
translation file in utf-8

Brutyn N. wrote:

i use utf8 for my database and i set this for each def in my controllers, all


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Alexander A.
Information Systems Department
Mediterranean Agronomic Institute of Chania
Tel.: +30 28210 35000 718
Email: removed_email_address@domain.invalid


#3

You need to specify the file charset of the YAML file in the YAML file.

e.g:
file_charset: latin1
hello: bonjour
bye: aurevoir

The localization lib tries to check the file charset but it does not
work
for me and surely for you too (duno why …) then it sets the charset to
‘ascii’ by default.

Thomas ? Any comments ?


#4

I had the same problem with Greek and solved it by saving the
translation file in utf-8

when i try to save the file in utf-8, the characters beoome squares, but
i
overwrite them with the correct letter like é à or è. Then i restart the
server
and i get error on the first line => invalid characters \357 …

what do u use for saving the file in utf8, i use scire from ruby.

thanks
Nick


#5

hey,

when can i find the YAML ???

u say latin1?

in my database are the correct chars, é is é , à is à , …
When i use latin 1, the site is wrong, but the export to pdf, excel are
correct
When i use utf8 the site is correct, but the export to pdf, excel are
wrong

anyone got another solution
what i do now is,

set the file in utf8,
translate the text ex école
then set the file in 8bit, école becomes �~ or something
then the display is correct

but i hope to find a better way.

thanks
Nick


#6

Brutyn N. wrote:

anyone got another solution
what i do now is,

set the file in utf8,
translate the text ex école
then set the file in 8bit, école becomes �~ or something
That’s actually correct. Whatever you’re using to view the text isn’t
handling UTF8. Given what you’ve said above, I’d suggest changing the
site over to latin1. Either that or convert from utf8 to latin1 (or one
of the Windows codepages) on the fly when you do your PDF or Excel
export.

The iconv library does a fine job of performing that sort of conversion.

Oh, and forget the idea of ‘correct chars’. There’s no such thing -
there is only agreement between different bits of software, or not.


#7

Nick I will have to ask you to forgive me for not being too carefull on
reading your email.
I used gettext for my problem and you are using the localization plugin
therefore my answer is not applicable to your problem.

Brutyn N. wrote:

thanks
Nick


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


Alexander A.
Information Systems Department
Mediterranean Agronomic Institute of Chania
Tel.: +30 28210 35000 718
Email: removed_email_address@domain.invalid


#8

hey,

i use this for all my different output (in databse the chars are what
they are,
é is é, à is à ,…)

#charsets for displaying the wierd characters correct
#show, edit, xml, utf8
#pdf, excel, import csv latin1, iso-8859-1

#setting the charset to utf8 for displaying the wierd characters on the
page
def output_to_html
@headers[“Content-Type”] = “text/html; charset=utf-8”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end
end

#setting the charset to latin1, iso-8859-1 for displaying the wierd
characters
on the pdf
def output_to_pdf
@headers[“Content-Type”] = “application/pdf; charset=iso-8859-
1”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES latin1’
end
end

#setting the charset to latin1, iso-8859-1 for displaying the wierd
characters
on the xls
def output_to_excel
@headers[“Content-Type”] = “application/vnd.ms-
excel;charset=iso-8859-1”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES latin1’
end
end

#setting the charset to latin1, iso-8859-1 for displaying the wierd
characters
in the database
def import_from_csv
@headers[“Content-Type”] = “text/html; charset=iso-8859-1”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES latin1’
end
end

#setting the charset to utf8 for displaying the wierd characters in the
xml file
def output_to_xml
@headers[“Content-Type”] = “text/xml; charset=utf-8”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end
end