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???
I had the same problem with Greek and solved it by saving the translation file in utf-8 Brutyn Nick wrote:> 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??? > > > _______________________________________________ > 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
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 ? On 1/5/06, Alexander Antonakakis <alexis@maich.gr> wrote:> > I had the same problem with Greek and solved it by saving the > translation file in utf-8 > > Brutyn Nick wrote: > > 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??? > > > > > > _______________________________________________ > > 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 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060105/a0cd1f74/attachment.html
> I had the same problem with Greek and solved it by saving the > translation file in utf-8when 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
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
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:>>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 > > _______________________________________________ > 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
Brutyn Nick wrote:> 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 somethingThat''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. -- Alex
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