# Multilanguage problem, need help

**URL:** <https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103>\
**Category:** Rails\
**Created:** [January 5, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103 "2006-01-05T12:15:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/1 "2006-01-05T12:15:00Z")

</div>

hey,

i use  
[http://mir.aculo.us/articles/2005/10/03/ruby-on-rails-i18n-revisited](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???

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 1:51pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/2 "2006-01-05T13:51:17Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/3 "2006-01-05T17:44:35Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/4 "2006-01-05T17:44:39Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/5 "2006-01-05T17:44:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/6 "2006-01-05T19:57:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 5, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/7 "2006-01-05T19:57:28Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Brutyn\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/5f8ce5/32.png) [@Brutyn\_N](https://www.ruby-forum.com/u/Brutyn_N)\
**Post date:** [January 7, 2006, 1:37pm UTC](https://www.ruby-forum.com/t/multilanguage-problem-need-help/90103/8 "2006-01-07T13:37:04Z")

</div>

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
