Forum: Ruby on Rails Multilanguage problem, need help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 Brutyn Nick (Guest)
on 2006-01-05 12:15
(Received via mailing list)
hey,

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

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???
D825f1046cfb8c49f667395a78c2beda?d=identicon&s=25 Alexander Antonakakis (Guest)
on 2006-01-05 13:51
(Received via mailing list)
I had the same problem with Greek and solved it by saving the
translation file in utf-8

Brutyn Nick wrote:
> i use utf8 for my database and i set this for each def in my controllers, all
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

--
Alexander Antonakakis
Information Systems Department
Mediterranean Agronomic Institute of Chania
Tel.: +30 28210 35000 718
Email: alexis@maich.gr
A5695819c07419f6197f2ff8b92bd2c0?d=identicon&s=25 Franck D'agostini (Guest)
on 2006-01-05 17:44
(Received via mailing list)
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 ?
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 Brutyn Nick (Guest)
on 2006-01-05 17:44
(Received via mailing list)
> 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
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 Brutyn Nick (Guest)
on 2006-01-05 17:44
(Received via mailing list)
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
D825f1046cfb8c49f667395a78c2beda?d=identicon&s=25 Alexander Antonakakis (Guest)
on 2006-01-05 19:57
(Received via mailing list)
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 Nick wrote:
> thanks
> Nick
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

--
Alexander Antonakakis
Information Systems Department
Mediterranean Agronomic Institute of Chania
Tel.: +30 28210 35000 718
Email: alexis@maich.gr
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-01-05 19:57
(Received via mailing list)
Brutyn Nick 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.
334ae822566107a2ea2b7a7cb88bd1d6?d=identicon&s=25 Brutyn Nick (Guest)
on 2006-01-07 13:37
(Received via mailing list)
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
This topic is locked and can not be replied to.