Sascha Ebach
2005-Jul-30 23:53 UTC
10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Some time ago I wrote the manual about using Gettext to translate your Rails app. It is still available under http://manuals.rubyonrails.com/read/book/16 and holds some good introductions and broader explanations about the subject. Recently I wanted to have my own weblog. I toyed around with a couple of PHP solutions, but I hated the prospect of having to maintain yet another pile of badly written PHP scripts. I already have enough of those :). So I turned to Typo[1]. But there was a problem. Typo doesn''t support *any* kind of translation as of 2005-07-31. So I talked to Tobias Luettke who is the maintainer of this wonderful blogging software (and all around nice guy) and asked if he was interested in getting a patch to gettextify typo. He said he would rather not integrate with Ruby-GetText[2] because it has binary dependencies with Iconv (which is optional) and Gettext. So I looked into integrating Ri18n[3] which is still very young but also excellent. The author has really thought more about nicer integration into rails apps which is a declared goal. So, instead of just making a patch for Typo I ended up writing a little guide on how to apply this strategy to every rails app. Now there is no excuse anymore for not making your rails apps translatable. Shame on you if you don''t ;). I know that a lot of people would like to see some support for translation (and broader localization) in Rails itself. So I thought in the meantime I would just post this to the Mailinglist and ask for feedback. If there are no problems I will also post it on the Wiki or the manuals section. As always before you start make sure that you use UTF-8 everywhere (also in the Database, MySQL 4.1.x supports this). Here we go. 10 Easy Steps To Make Your Rails Apps Multilingual (I18N) 1) Read the USAGE of ri18n on http://ri18n.berlios.de/rdoc/files/USAGE.html. Repeat two times. Keep referring to it if you have questions along the way. 2) Check out the fresh svn trunk into the vendor dir: cd $RAILS_ROOT/vendor svn checkout svn://svn.berlios.de/ri18n/trunk ri18n 3) Now add this path to the ADDITIONAL_LOAD_PATHS array in $RAILS_ROOT/config/environment.rb so that it reads: ADDITIONAL_LOAD_PATHS.concat %w( # ... other entries vendor vendor/ri18n/lib # ... other entries ).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) } 4) Now require necessary ri18n library files in $RAILS_ROOT/config/environment.rb: # Load included libraries. # ... other libraries require ''gettext'' require ''i18nservice'' 5) Create a locale dir in the base dir of your application: mkdir $RAILS_ROOT/locale 6) Ri18n has to be configured. At the end of your $RAILS_ROOT/config/environment.rb file add: $KCODE = ''u'' # lets go unicode, you will have less trouble ... require ''jcode'' # and use the right string methods for utf-8 # The directory where translation files (PO files) will go I18nService.instance.po_dir = "#{RAILS_ROOT}/locale" # let''s use German everywhere I18nService.instance.lang = ''de'' Notice that the last line just sets your language to German on a global basis. If you want to decide which language to use in a more dynamic manner go and take a look at the old manual: http://manuals.rubyonrails.com/read/book/16. It should be easy to adapt the strategy I present there to your own needs. 7) You will want to have a way to harvest your files. Ri18n has a built-in harvester that is controlled by a rake task. So go ahead and add a rake task to the end of $RAILS_ROOT/Rakefile: task :gettext do $:.unshift ''vendor/ri18n/lib'' require ''gettext'' require ''i18nservice'' I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' desc ''Run the ri18n harvester on this application'' Rake::GettextTask.new do |t| # add all desired langues here t.new_langs = [''de'', ''fr''] # add all desired paths here t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] t.verbose = true end end 8) Now you can call `rake gettext` in your $RAILS_ROOT and the harvester will collect all the strings in your files which looks something like this: dw@colinux: /home/dw/rails/typo: $ rake gettext (in /home/dw/rails/typo) I18n messages in app/views/articles/index.rhtml: * Good Morning * Hello * Good Bye 9) Well, now, you will actually have to go through your source code and translate it. If you forget how remember step 1. Every time you add or change a translation, just repeat step 8. 10) Most important: Have fun and be proud that from now on you can say that, yes, your apps will also (at least potentially) be understood by the majority of the internet population[4]. [1] http://typo.leetsoft.com/trac/ [2] http://ponx.s5.xrea.com/hiki/ruby-gettext.html [3] http://ri18n.berlios.de/ [4] Which was about 64,2 % of the internet population in 2004 http://global-reach.biz/globstats/index.php3 Now, please tell me if you find this information useful and more important if you find anything to improve on. Sascha Ebach
Wilson
2005-Jul-30 23:57 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
This is awesome. Thank you for blazing a trail. Sascha Ebach wrote:> So, instead of just making a patch for Typo I ended up writing a little > guide on how to apply this strategy to every rails app. Now there is no > excuse anymore for not making your rails apps translatable. Shame on you > if you don''t ;). I know that a lot of people would like to see some > support for translation (and broader localization) in Rails itself. So I > thought in the meantime I would just post this to the Mailinglist and > ask for feedback. If there are no problems I will also post it on the > Wiki or the manuals section. >
Andrew Stone
2005-Jul-30 23:58 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Thanks Sascha, this email has just been starred. I''m currently working on a app that we wanted to make multi-lingual. After i get some basics, currently working on getting file upload integrated, I''ll take a closer look at this. thanks again, andy -- Andrew Stone
Jamis Buck
2005-Jul-31 00:32 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
On Jul 30, 2005, at 5:53 PM, Sascha Ebach wrote:> 9) Well, now, you will actually have to go through your source code > and translate it. If you forget how remember step 1. Every time you > add or change a translation, just repeat step 8.I completely understand the importance of i18n, and support the effort. But how do most people on a budget translate their apps, and maintain the translations? It''s not like we can all afford to keep a polyglot on staff... and if you happen to find a willing volunteer, who''s to say that person will be available and willing to help later, when you need to change or add a translation? Anyway, just curious how these issues are handled by those who deal with i18n, esp. in an open source environment. - Jamis
Tobias Luetke
2005-Jul-31 00:40 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Fantastic Sascha, Lets get this integrated in typo proper then.. On 7/30/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote:> Recently I wanted to have my own weblog. I toyed around with a couple of > PHP solutions, but I hated the prospect of having to maintain yet > another pile of badly written PHP scripts. I already have enough of > those :). So I turned to Typo[1]. But there was a problem. Typo doesn''t > support *any* kind of translation as of 2005-07-31. So I talked to > Tobias Luettke who is the maintainer of this wonderful blogging software > (and all around nice guy) and asked if he was interested in getting a > patch to gettextify typo. He said he would rather not integrate with > Ruby-GetText[2] because it has binary dependencies with Iconv (which is > optional) and Gettext. So I looked into integrating Ri18n[3] which is > still very young but also excellent. The author has really thought more > about nicer integration into rails apps which is a declared goal. > > So, instead of just making a patch for Typo I ended up writing a little > guide on how to apply this strategy to every rails app. Now there is no > excuse anymore for not making your rails apps translatable. Shame on you > if you don''t ;). I know that a lot of people would like to see some > support for translation (and broader localization) in Rails itself. So I > thought in the meantime I would just post this to the Mailinglist and > ask for feedback. If there are no problems I will also post it on the > Wiki or the manuals section.-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
Colin Fleming
2005-Jul-31 00:56 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Any idea how well ri18n handles charset conversions? The doc says it''s a bit flakey, have you tried it out? I have an app that doesn''t need translation, but I do need arbitrary charset conversion and I''d rather avoid the dependency on Iconv as well if I could. Cheers, Colin On 31/07/05, Tobias Luetke <tobias.luetke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Fantastic Sascha, > > Lets get this integrated in typo proper then.. > > On 7/30/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote: > > > Recently I wanted to have my own weblog. I toyed around with a couple of > > PHP solutions, but I hated the prospect of having to maintain yet > > another pile of badly written PHP scripts. I already have enough of > > those :). So I turned to Typo[1]. But there was a problem. Typo doesn''t > > support *any* kind of translation as of 2005-07-31. So I talked to > > Tobias Luettke who is the maintainer of this wonderful blogging software > > (and all around nice guy) and asked if he was interested in getting a > > patch to gettextify typo. He said he would rather not integrate with > > Ruby-GetText[2] because it has binary dependencies with Iconv (which is > > optional) and Gettext. So I looked into integrating Ri18n[3] which is > > still very young but also excellent. The author has really thought more > > about nicer integration into rails apps which is a declared goal. > > > > So, instead of just making a patch for Typo I ended up writing a little > > guide on how to apply this strategy to every rails app. Now there is no > > excuse anymore for not making your rails apps translatable. Shame on you > > if you don''t ;). I know that a lot of people would like to see some > > support for translation (and broader localization) in Rails itself. So I > > thought in the meantime I would just post this to the Mailinglist and > > ask for feedback. If there are no problems I will also post it on the > > Wiki or the manuals section. > > -- > Tobi > http://www.snowdevil.ca - Snowboards that don''t suck > http://typo.leetsoft.com - Open source weblog engine > http://blog.leetsoft.com - Technical weblog > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sascha Ebach
2005-Jul-31 00:58 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Jamis Buck wrote:> I completely understand the importance of i18n, and support the effort. > But how do most people on a budget translate their apps, and maintain > the translations? It''s not like we can all afford to keep a polyglot on > staff... and if you happen to find a willing volunteer, who''s to say > that person will be available and willing to help later, when you need > to change or add a translation? > > Anyway, just curious how these issues are handled by those who deal > with i18n, esp. in an open source environment.When you say "on a budget" and "open source environment" you probably don''t mean the same kind of project. The translations of any OS project will only be as good as its contributors. What is more important for me, personally, is that I have a way to be able to translate a web app at all. Clearly the maintainer(s) of the project will have to have thought about that upfront. That is often the not so easy part. For example if you have to account for your language going from right-to-left (arabic) or from top-to-bottom (chinese). In the case of Typo, which I currently need for a German weblog I plan to start in 2 or 3 weeks, I don''t even have the chance of doing my translations. Unless I fork Typo which is clearly not what I want to do. I think this goes for a lot of other packages, too. Take Drupal[1] for example. The German translation usually lacks behind months until someone with a need to do it comes along and just translates it. And if you plan to use it commercially than you might not even be satisified with the translation quality of a package. Good to know that you can do it yourself or hire someone to do it for you ... My experience has been that the translations are second class. But if a package puts you into the position to change that yourself, I don''t find that so bad. Everything would be so much easier if we only had one language, currency, time zone, date format, char set, ... It is just a fact of (developer) life that we don''t. So it would be awesome if this would be something that would be planned for upfront by more (OS) developers. This is a particularly weak point of Rails (and more so Ruby). It adds more complexity to software development, yes, but IMO this is just part of the job description of a good developer. It gets better. Slowly, but surely. Sascha [1] http://www.drupal.org
Sascha Ebach
2005-Jul-31 01:04 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Colin Fleming wrote:> Any idea how well ri18n handles charset conversions? The doc says it''s > a bit flakey, have you tried it out? I have an app that doesn''t need > translation, but I do need arbitrary charset conversion and I''d rather > avoid the dependency on Iconv as well if I could.Hm, you are going to have a hard time with charset conversion without Iconv. Charset conversion is really hard. And Iconv is a package which is easily available on many platforms. There is no easier conversion than Iconv. Please correct me if I am wrong. If you want to do conversions with r18n you also have to have Iconv. Sascha
Dylan Egan
2005-Jul-31 01:12 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Hi Sascha, Great guide and I think this is just what I am looking for. I have a few clients who depend heavily on the Asian market, but are based in Australia, so if I can get this working well enough I should be able to have their site translated into atleast one other language soon enough. Dylan.> Some time ago I wrote the manual about using Gettext to translate your > Rails app. It is still available under > http://manuals.rubyonrails.com/read/book/16 and holds some good > introductions and broader explanations about the subject. > > So, instead of just making a patch for Typo I ended up writing a > little guide on how to apply this strategy to every rails app. Now > there is no excuse anymore for not making your rails apps > translatable. Shame on you if you don''t ;). I know that a lot of > people would like to see some support for translation (and broader > localization) in Rails itself. So I thought in the meantime I would > just post this to the Mailinglist and ask for feedback. If there are > no problems I will also post it on the Wiki or the manuals section.
Sascha Ebach
2005-Jul-31 01:22 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Tobias Luetke wrote:> Fantastic Sascha, > > Lets get this integrated in typo proper then..Great. Tried to ping you on IRC, no luck. If you don''t catch me there I still have a couple of questions about the patch. I will just mail you off list. Sascha
masayoshi takahashi
2005-Jul-31 02:33 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
agreed. Sascha''s solution is great, but "use UTF-8 everywhere" is never "easy step" for me. I (and many Japanese web developers) usually use EUC-JP(in scripts) and Shift_JIS(in HTML templates) and ISO-2022-JP (in E-mails) in one application. In addition, there is one more problem: ActiveRecord. Error messages of it are not supported in Japanese. So I hacked ActiveRecord::Base::human_attribute_name as bellow def human_attribute_name(attribute_key_name) #:nodoc: table = self.human_attribute_name_table if table && table[attribute_key_name] return table[attribute_key_name] end attribute_key_name.humanize end and add ''cattr_accessor :human_attribute_name_table'' . But I know it''s not smart solution. We need total and consistent solution for i18n/l10n in rails. Regards, Masayoshi Takahashi 2005/7/31, Colin Fleming <colin.mailinglist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Any idea how well ri18n handles charset conversions? The doc says it''s > a bit flakey, have you tried it out? I have an app that doesn''t need > translation, but I do need arbitrary charset conversion and I''d rather > avoid the dependency on Iconv as well if I could. > > Cheers, > Colin > > On 31/07/05, Tobias Luetke <tobias.luetke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Fantastic Sascha, > > > > Lets get this integrated in typo proper then.. > > > > On 7/30/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote: > > > > > Recently I wanted to have my own weblog. I toyed around with a couple of > > > PHP solutions, but I hated the prospect of having to maintain yet > > > another pile of badly written PHP scripts. I already have enough of > > > those :). So I turned to Typo[1]. But there was a problem. Typo doesn''t > > > support *any* kind of translation as of 2005-07-31. So I talked to > > > Tobias Luettke who is the maintainer of this wonderful blogging software > > > (and all around nice guy) and asked if he was interested in getting a > > > patch to gettextify typo. He said he would rather not integrate with > > > Ruby-GetText[2] because it has binary dependencies with Iconv (which is > > > optional) and Gettext. So I looked into integrating Ri18n[3] which is > > > still very young but also excellent. The author has really thought more > > > about nicer integration into rails apps which is a declared goal. > > > > > > So, instead of just making a patch for Typo I ended up writing a little > > > guide on how to apply this strategy to every rails app. Now there is no > > > excuse anymore for not making your rails apps translatable. Shame on you > > > if you don''t ;). I know that a lot of people would like to see some > > > support for translation (and broader localization) in Rails itself. So I > > > thought in the meantime I would just post this to the Mailinglist and > > > ask for feedback. If there are no problems I will also post it on the > > > Wiki or the manuals section. > > > > -- > > Tobi > > http://www.snowdevil.ca - Snowboards that don''t suck > > http://typo.leetsoft.com - Open source weblog engine > > http://blog.leetsoft.com - Technical weblog > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Wilson
2005-Jul-31 03:52 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
I''ve never been able to figure this out.. Maybe you can explain? What do Shift-JIS, EUC-JP, and the others offer that UTF-8 doesn''t? Surely it''s not just for text art on 2ch. =) masayoshi takahashi wrote:> agreed. Sascha''s solution is great, but "use UTF-8 everywhere" > is never "easy step" for me. I (and many Japanese web developers) > usually use EUC-JP(in scripts) and Shift_JIS(in HTML templates) > and ISO-2022-JP (in E-mails) in one application. >
Ben Myles
2005-Jul-31 05:30 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
What could be really cool is a gem that interfaces with one of the online translation sites and generates a translation of each page in real time, depending on the language chosen. I know these automated translations aren''t all that good (and sometimes incredibly poor) but it''s usually enough to get the overall ''idea'' of a page''s content. Does anyone know of such a translation site that provides a free SOAP API? Does Google? Ben
Colin Fleming
2005-Jul-31 17:37 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Ok, I''d figured that, I was just wondering if there was a pure-ruby solution (although Iconv does integrate well with Ruby). Thanks, Colin On 31/07/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote:> Hm, you are going to have a hard time with charset conversion without > Iconv. Charset conversion is really hard. And Iconv is a package which > is easily available on many platforms. There is no easier conversion > than Iconv. Please correct me if I am wrong. > > If you want to do conversions with r18n you also have to have Iconv. > > Sascha
Sascha Ebach
2005-Jul-31 18:30 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Colin Fleming wrote:> Ok, I''d figured that, I was just wondering if there was a pure-ruby > solution (although Iconv does integrate well with Ruby).You could probably do one in Ruby. But something like charset conversion is an ideal thing to be implemented in a compiled language (c fans correct me if I am wrong). Essentially lots of big lookup tables. If implemnted in Ruby or any other dynamic language you would have a major performance bottleneck. Depending on what you do with it, this could be a problem. Sascha
Antony Joseph
2005-Aug-01 01:34 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Colin, If you are looking for a pure ruby solution check out the module at http://www.logicden.com/site/downloads ----- Original Message ----- From: "Colin Fleming" <colin.mailinglist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] 10 Easy Steps To Make Your Rails Apps Multilingual (I18N) Date: Sun, 31 Jul 2005 19:37:23 +0200> > Ok, I''d figured that, I was just wondering if there was a pure-ruby > solution (although Iconv does integrate well with Ruby). > > Thanks, > Colin > > On 31/07/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote: > > Hm, you are going to have a hard time with charset conversion without > > Iconv. Charset conversion is really hard. And Iconv is a package which > > is easily available on many platforms. There is no easier conversion > > than Iconv. Please correct me if I am wrong. > > > > If you want to do conversions with r18n you also have to have Iconv. > > > > Sascha > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/railsAntony Joseph http://www.logicden.com https://workeffort.dev.java.net http://www.detroitjug.org -- _______________________________________________ NEW! Lycos Dating Search. The only place to search multiple dating sites at once. http://datingsearch.lycos.com
Benjamin Jackson
2005-Aug-02 15:13 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
+100 On Jul 30, 2005, at 8:53 PM, Sascha Ebach wrote:> Some time ago I wrote the manual about using Gettext to translate your > Rails app. It is still available under > http://manuals.rubyonrails.com/read/book/16 and holds some good > introductions and broader explanations about the subject. > > Recently I wanted to have my own weblog. I toyed around with a couple > of PHP solutions, but I hated the prospect of having to maintain yet > another pile of badly written PHP scripts. I already have enough of > those :). So I turned to Typo[1]. But there was a problem. Typo > doesn''t support *any* kind of translation as of 2005-07-31. So I > talked to Tobias Luettke who is the maintainer of this wonderful > blogging software (and all around nice guy) and asked if he was > interested in getting a patch to gettextify typo. He said he would > rather not integrate with Ruby-GetText[2] because it has binary > dependencies with Iconv (which is optional) and Gettext. So I looked > into integrating Ri18n[3] which is still very young but also > excellent. The author has really thought more about nicer integration > into rails apps which is a declared goal. > > So, instead of just making a patch for Typo I ended up writing a > little guide on how to apply this strategy to every rails app. Now > there is no excuse anymore for not making your rails apps > translatable. Shame on you if you don''t ;). I know that a lot of > people would like to see some support for translation (and broader > localization) in Rails itself. So I thought in the meantime I would > just post this to the Mailinglist and ask for feedback. If there are > no problems I will also post it on the Wiki or the manuals section. > > As always before you start make sure that you use UTF-8 everywhere > (also in the Database, MySQL 4.1.x supports this). > > Here we go. > > 10 Easy Steps To Make Your Rails Apps Multilingual (I18N) > > 1) Read the USAGE of ri18n on > http://ri18n.berlios.de/rdoc/files/USAGE.html. Repeat two times. Keep > referring to it if you have questions along the way. > > 2) Check out the fresh svn trunk into the vendor dir: > > cd $RAILS_ROOT/vendor > svn checkout svn://svn.berlios.de/ri18n/trunk ri18n > > 3) Now add this path to the ADDITIONAL_LOAD_PATHS array in > $RAILS_ROOT/config/environment.rb so that it reads: > > ADDITIONAL_LOAD_PATHS.concat %w( > # ... other entries > vendor > vendor/ri18n/lib > # ... other entries > ).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| > File.directory?(dir) } > > 4) Now require necessary ri18n library files in > $RAILS_ROOT/config/environment.rb: > > # Load included libraries. > # ... other libraries > require ''gettext'' > require ''i18nservice'' > > 5) Create a locale dir in the base dir of your application: > > mkdir $RAILS_ROOT/locale > > 6) Ri18n has to be configured. At the end of your > $RAILS_ROOT/config/environment.rb file add: > > $KCODE = ''u'' # lets go unicode, you will have less trouble ... > require ''jcode'' # and use the right string methods for utf-8 > # The directory where translation files (PO files) will go > I18nService.instance.po_dir = "#{RAILS_ROOT}/locale" > # let''s use German everywhere > I18nService.instance.lang = ''de'' > > Notice that the last line just sets your language to German on a > global basis. If you want to decide which language to use in a more > dynamic manner go and take a look at the old manual: > http://manuals.rubyonrails.com/read/book/16. It should be easy to > adapt the strategy I present there to your own needs. > > 7) You will want to have a way to harvest your files. Ri18n has a > built-in harvester that is controlled by a rake task. So go ahead and > add a rake task to the end of $RAILS_ROOT/Rakefile: > > task :gettext do > $:.unshift ''vendor/ri18n/lib'' > require ''gettext'' > require ''i18nservice'' > I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' > desc ''Run the ri18n harvester on this application'' > Rake::GettextTask.new do |t| > # add all desired langues here > t.new_langs = [''de'', ''fr''] > # add all desired paths here > t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] > t.verbose = true > end > end > > 8) Now you can call `rake gettext` in your $RAILS_ROOT and the > harvester will collect all the strings in your files which looks > something like this: > > dw@colinux: /home/dw/rails/typo: > $ rake gettext > (in /home/dw/rails/typo) > I18n messages in app/views/articles/index.rhtml: > * Good Morning > * Hello > * Good Bye > > 9) Well, now, you will actually have to go through your source code > and translate it. If you forget how remember step 1. Every time you > add or change a translation, just repeat step 8. > > 10) Most important: Have fun and be proud that from now on you can say > that, yes, your apps will also (at least potentially) be understood by > the majority of the internet population[4]. > > > [1] http://typo.leetsoft.com/trac/ > [2] http://ponx.s5.xrea.com/hiki/ruby-gettext.html > [3] http://ri18n.berlios.de/ > [4] Which was about 64,2 % of the internet population in 2004 > http://global-reach.biz/globstats/index.php3 > > Now, please tell me if you find this information useful and more > important if you find anything to improve on. > > Sascha Ebach > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >___________________ Ben Jackson Diretor de Desenvolvimento +55 (21) 9997-0593 ben-p14LI7ZcAE/pVLaUnt/cCQC/G2K4zDHf@public.gmane.org http://www.incomumdesign.com
Joshua Sierles
2005-Aug-02 16:14 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
I know this is a bad practice, but I have tons of ''legacy'' PHP stuff that uses iso-8859-1 encoding. How can I use this module effectively with this encoding for now? Specifying the content type of the .po file doesn''t seem to have any effect (The harvester aborts when it finds a bad character). Joshua Sierles _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sascha Ebach
2005-Aug-02 17:04 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Joshua Sierles wrote:> I know this is a bad practice, but I have tons of ''legacy'' PHP stuff > that uses iso-8859-1 encoding. How can I use this module effectively > with this encoding for now? Specifying the content type of the .po file > doesn''t seem to have any effect (The harvester aborts when it finds a > bad character).Your best bet is to convert the files with iconv on the command line. (something like that, untested) $iconv -f "iso-8859-1" -t "UTF-8" legacy.php > new.utf8.php As always, make backup before you start. Sascha
David Geary
2005-Aug-02 18:08 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Thanks Sascha, for posting this. At first I was skeptical, but your steps were, in fact, easy. One thing I''ve noticed, however. When I add more text to the app, run "rake gettext" and edit my PO file, I''ve got to restart WEBrick, or I just see the msgid. IOW, if I add <%= _(''greeting'') %> to an rhtml file and msgid="greeting"...msgstr="hello" in en.po, I see greeting until I restart WEBrick and then I see hello. Is it really necessary to restart WEBrick every time I add strings? Thanks again for posting this. david Le 05-07-30 à 17:53, Sascha Ebach a écrit :> Some time ago I wrote the manual about using Gettext to translate > your Rails app. It is still available under http:// > manuals.rubyonrails.com/read/book/16 and holds some good > introductions and broader explanations about the subject. > > Recently I wanted to have my own weblog. I toyed around with a > couple of PHP solutions, but I hated the prospect of having to > maintain yet another pile of badly written PHP scripts. I already > have enough of those :). So I turned to Typo[1]. But there was a > problem. Typo doesn''t support *any* kind of translation as of > 2005-07-31. So I talked to Tobias Luettke who is the maintainer of > this wonderful blogging software (and all around nice guy) and > asked if he was interested in getting a patch to gettextify typo. > He said he would rather not integrate with Ruby-GetText[2] because > it has binary dependencies with Iconv (which is optional) and > Gettext. So I looked into integrating Ri18n[3] which is still very > young but also excellent. The author has really thought more about > nicer integration into rails apps which is a declared goal. > > So, instead of just making a patch for Typo I ended up writing a > little guide on how to apply this strategy to every rails app. Now > there is no excuse anymore for not making your rails apps > translatable. Shame on you if you don''t ;). I know that a lot of > people would like to see some support for translation (and broader > localization) in Rails itself. So I thought in the meantime I would > just post this to the Mailinglist and ask for feedback. If there > are no problems I will also post it on the Wiki or the manuals > section. > > As always before you start make sure that you use UTF-8 everywhere > (also in the Database, MySQL 4.1.x supports this). > > Here we go. > > 10 Easy Steps To Make Your Rails Apps Multilingual (I18N) > > 1) Read the USAGE of ri18n on http://ri18n.berlios.de/rdoc/files/ > USAGE.html. Repeat two times. Keep referring to it if you have > questions along the way. > > 2) Check out the fresh svn trunk into the vendor dir: > > cd $RAILS_ROOT/vendor > svn checkout svn://svn.berlios.de/ri18n/trunk ri18n > > 3) Now add this path to the ADDITIONAL_LOAD_PATHS array in > $RAILS_ROOT/config/environment.rb so that it reads: > > ADDITIONAL_LOAD_PATHS.concat %w( > # ... other entries > vendor > vendor/ri18n/lib > # ... other entries > ).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| > File.directory?(dir) } > > 4) Now require necessary ri18n library files in $RAILS_ROOT/config/ > environment.rb: > > # Load included libraries. > # ... other libraries > require ''gettext'' > require ''i18nservice'' > > 5) Create a locale dir in the base dir of your application: > > mkdir $RAILS_ROOT/locale > > 6) Ri18n has to be configured. At the end of your $RAILS_ROOT/ > config/environment.rb file add: > > $KCODE = ''u'' # lets go unicode, you will have less trouble ... > require ''jcode'' # and use the right string methods for utf-8 > # The directory where translation files (PO files) will go > I18nService.instance.po_dir = "#{RAILS_ROOT}/locale" > # let''s use German everywhere > I18nService.instance.lang = ''de'' > > Notice that the last line just sets your language to German on a > global basis. If you want to decide which language to use in a more > dynamic manner go and take a look at the old manual: http:// > manuals.rubyonrails.com/read/book/16. It should be easy to adapt > the strategy I present there to your own needs. > > 7) You will want to have a way to harvest your files. Ri18n has a > built-in harvester that is controlled by a rake task. So go ahead > and add a rake task to the end of $RAILS_ROOT/Rakefile: > > task :gettext do > $:.unshift ''vendor/ri18n/lib'' > require ''gettext'' > require ''i18nservice'' > I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' > desc ''Run the ri18n harvester on this application'' > Rake::GettextTask.new do |t| > # add all desired langues here > t.new_langs = [''de'', ''fr''] > # add all desired paths here > t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] > t.verbose = true > end > end > > 8) Now you can call `rake gettext` in your $RAILS_ROOT and the > harvester will collect all the strings in your files which looks > something like this: > > dw@colinux: /home/dw/rails/typo: > $ rake gettext > (in /home/dw/rails/typo) > I18n messages in app/views/articles/index.rhtml: > * Good Morning > * Hello > * Good Bye > > 9) Well, now, you will actually have to go through your source code > and translate it. If you forget how remember step 1. Every time you > add or change a translation, just repeat step 8. > > 10) Most important: Have fun and be proud that from now on you can > say that, yes, your apps will also (at least potentially) be > understood by the majority of the internet population[4]. > > > [1] http://typo.leetsoft.com/trac/ > [2] http://ponx.s5.xrea.com/hiki/ruby-gettext.html > [3] http://ri18n.berlios.de/ > [4] Which was about 64,2 % of the internet population in 2004 > http://global-reach.biz/globstats/index.php3 > > Now, please tell me if you find this information useful and more > important if you find anything to improve on. > > Sascha Ebach > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sascha Ebach
2005-Aug-02 18:54 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
David Geary wrote:> Thanks Sascha, for posting this. At first I was skeptical, but your > steps were, in fact, easy.Yeah, thanks, there are a couple of other things that really don''t work right. I will contact the author and keep you posted.> > One thing I''ve noticed, however. When I add more text to the app, run > "rake gettext" and edit my PO file, I''ve got to restart WEBrick, or I > just see the msgid. IOW, if I add <%= _(''greeting'') %> to an rhtml file > and msgid="greeting"...msgstr="hello" in en.po, I see greeting until I > restart WEBrick and then I see hello. > > Is it really necessary to restart WEBrick every time I add strings?When you are in development mode it should work. I''ll put it on my list and check for it. But if I remeber correctly it worked on Debian / lighttpd. Sascha
masayoshi takahashi
2005-Aug-03 06:58 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
2005/7/31, Wilson <defiler-ifvz4xmYPRU@public.gmane.org>:> I''ve never been able to figure this out.. Maybe you can explain? > What do Shift-JIS, EUC-JP, and the others offer that UTF-8 doesn''t?They offer legacy and stable environments. We must use Shift JIS as HTML for mobile agent, and should use ISO-2022-JP as e-mail. If we use UTF-8, we should use encoding converter, but converting japanese encoding is troublesome(ex. windows GAIJI is used in HTML which has charset=Shift_JIS). In addition, We use many tools that don''t support UTF-8. It''s not impossible to change all tools, but... P.S. A few days ago, I met some Japanese railers, and I asked about this problem. They advised me to use UTF-8. uummmmm...> Surely it''s not just for text art on 2ch. =)(^_^;; Regards, Masayoshi Takahashi> masayoshi takahashi wrote: > > agreed. Sascha''s solution is great, but "use UTF-8 everywhere" > > is never "easy step" for me. I (and many Japanese web developers) > > usually use EUC-JP(in scripts) and Shift_JIS(in HTML templates) > > and ISO-2022-JP (in E-mails) in one application. > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Joshua Sierles
2005-Aug-03 08:41 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Actually I meant the po files themselves. The rake gettext command fails because there are accented characters in my .po files. Joshua On 8/2/05, Sascha Ebach <se-eFwX6J65rk9VioaHkBSlcw02NpfuEekPhC4ANOJQIlc@public.gmane.org> wrote:> > Joshua Sierles wrote: > > I know this is a bad practice, but I have tons of ''legacy'' PHP stuff > > that uses iso-8859-1 encoding. How can I use this module effectively > > with this encoding for now? Specifying the content type of the .po file > > doesn''t seem to have any effect (The harvester aborts when it finds a > > bad character). > > Your best bet is to convert the files with iconv on the command line. > > (something like that, untested) > $iconv -f "iso-8859-1" -t "UTF-8" legacy.php > new.utf8.php > > As always, make backup before you start. > > Sascha > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sascha Ebach
2005-Aug-03 11:54 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Joshua Sierles wrote:> Actually I meant the po files themselves. The rake gettext command > fails because there are accented characters in my .po files.Haven''t tested that, yet, but the harvester fails on a couple of other things, too. For example: _(''"test"'') becomes msgid ""test"" which should be msgid "\"test\"" I will contact the author about this today. Sascha
Jean-Christophe Michel
2005-Aug-04 20:42 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Hi, Thanks for this good i18N guide. I wonder if it would be possible to use some caching system together with the before_filter, to avoid translation on the fly for each request. Maybe it''s not worth? -- Jean-Christophe Michel
Sascha Ebach
2005-Aug-04 21:46 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Jean-Christophe Michel wrote:> Hi, > > Thanks for this good i18N guide. > > I wonder if it would be possible to use some caching system together > with the before_filter, to avoid translation on the fly for each > request. Maybe it''s not worth?I wonder what you mean by that. Can you explain a little more? What exactly should be cached? Sascha
Jean-Christophe Michel
2005-Aug-04 22:49 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Sascha Ebach wrote:>> I wonder if it would be possible to use some caching system together >> with the before_filter, to avoid translation on the fly for each >> request. Maybe it''s not worth? > > I wonder what you mean by that. Can you explain a little more? What > exactly should be cached?Maybe I''m wrong. I thought string translation through _() calls was made at runtime, while the static strings translated with gettext don''t depend on the request. So my reaction was: to optimize this, have a cache after the translation. Ruby files with strings translated could be cached as long as no modification is made to the source or to the translation files. -- Jean-Christophe Michel
Sascha Ebach
2005-Aug-04 23:45 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Jean-Christophe Michel wrote:> Maybe I''m wrong. I thought string translation through _() calls was made > at runtime, while the static strings translated with gettext don''t > depend on the request. So my reaction was: to optimize this, have a > cache after the translation. Ruby files with strings translated could be > cached as long as no modification is made to the source or to the > translation files.Ok, now I understand. Yes, I guess a simple marshal would work for that. I suggest you make a feature request. At the moment the online way I know to do that is to mail the author Denis Mertz. You can find the email on the bottom of http://ri18n.berlios.de/. Sascha
Govinda Pfister
2005-Aug-10 10:10 UTC
RE:10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Hello Sascha, great work with that I18N-Guide. I tried this out yesterday and nearly everything works fine for me. I just have one problem: The command "rake gettext" seems to generate the po-files with ascii-encoding not utf-8. At least if I try to open these po-files with poEdit I get the error message "cannot convert from encoding ascii". Furthermore if use german characters in the like ''ß'' or ''ü'' in the de.po-file I get an error message when the rails environment is loaded. "./script/../config/../vendor/gems/ri18n-0.0.3/lib/ri18n/po.rb:22:in `iconv'':Iconv::IllegalSequence: "ß %i einen Wurm"..." What is wrong? Help is as always very appreciated! Govinda This is my configuration (I did everything according to 10 easy steps manual): environment.rb ---------------------- require ''gettext'' require ''i18nservice'' $KCODE = ''UTF8'' # lets go unicode, you will have less trouble ... require ''jcode'' # and use the right string methods for utf-8 # The directory where translation files (PO files) will go I18nService.instance.po_dir = "#{RAILS_ROOT}/locale" # let''s use German everywhere I18nService.instance.lang = ''de'' rakefile --------------------------- task :gettext do $:.unshift ''vendor/gems/ri18n-0.0.3/lib'' require ''gettext'' require ''i18nservice'' I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' desc ''Run the ri18n harvester on this application'' Rake::GettextTask.new do |t| # add all desired langues here t.new_langs = [''de'', ''en''] # add all desired paths here t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] t.verbose = true end end Testclass "Duck" to do initial I18N tests ----------------------------------------- class Duck def talk puts _(''I talk like a duck'') puts _(''Quack Quack !!'') end def walk puts _(''I walk like a duck'') end def eat_worms 0.upto(4) do |i| puts n_(''I ate %i worm'', ''I ate %i worms'', i) end end end de.po ------------------------------------------------ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "POT-Creation-Date: 2002-12-10 22:11+0100\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL-2l5V8CiXCHs@public.gmane.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ASCII\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n == 0;\n" msgid "I ate %i worm" msgid_plural "I ate %i worms" msgstr[0] "Ich aß %i einen Wurm" msgstr[1] "Ich aß %i Würmer" msgid "I talk like a duck" msgstr "Ich spreche wie eine Ente" msgid "I walk like a duck" msgstr "Ich lauf wie eine Ente" msgid "Quack Quack !!" msgstr "Quack Quack (Deutsch)" en.po ----------------------------------------------------------------- # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "POT-Creation-Date: 2002-12-10 22:11+0100\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL-2l5V8CiXCHs@public.gmane.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ASCII\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n == 0;\n" msgid "I ate %i worm" msgid_plural "I ate %i worms" msgstr[0] "I ate %i worm" msgstr[1] "I ate %i worms" msgid "I talk like a duck" msgstr "I talk like a duck" msgid "I walk like a duck" msgstr "I walk like a duck" msgid "Quack Quack !!" msgstr "Quack Quack (Englisch)" application.rb ------------------------------------------ # start: utf8-support # Content-Type HTTP header so that Apache and other web servers dont serve up some incorrect Content-Type before_filter :set_default_content_type def set_content_type(content_type) @response.headers["Content-Type"] = content_type end def set_default_content_type set_content_type("text/html; charset=utf-8") end # end: utf8-support Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min. weltweit telefonieren! http://freephone.web.de/?mc=021201 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Sascha Ebach
2005-Aug-10 10:58 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Govinda Pfister wrote:> Hello Sascha, > > great work with that I18N-Guide. > > I tried this out yesterday and nearly everything works fine for me. > > I just have one problem: > > The command "rake gettext" seems to generate the po-files with > ascii-encoding not utf-8. > > At least if I try to open these po-files with poEdit I get the error > message "cannot convert from encoding ascii". > > Furthermore if use german characters in the like ''ß'' or ''ü'' in the > de.po-file I get an error message when the rails environment is loaded. > > "./script/../config/../vendor/gems/ri18n-0.0.3/lib/ri18n/po.rb:22:in > `iconv'':Iconv::IllegalSequence: "ß %i einen Wurm"..." > > What is wrong? Help is as always very appreciated!Yes, that was my mistake. I forgot to specify the $KCODE in the rake task. ri18n decides which charset to use by looking at it. So this is how it is supposed to look: task :gettext do $:.unshift ''vendor/ri18n/lib'' # don''t forget the $KCODE $KCODE = ''u'' require ''gettext'' require ''i18nservice'' I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' desc ''Run the ri18n harvester on this application'' Rake::GettextTask.new do |t| # add all desired langues here t.new_langs = [''de'', ''fr''] # add all desired paths here t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] t.verbose = true end end Sascha Ebach
Govinda Pfister
2005-Aug-10 12:28 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Hello, now I do not get the error message any more, but an irb session (the rails console) shows that something is still not working properly: irb session --------- >> ente = Duck.new => # >> ente.eat_worms Ich aà 0 Würmer Ich aà 1 einen Wurm Ich aà 2 Würmer Ich aà 3 Würmer Ich aà 4 Würmer => 0 >> The translation should be "Ich aß 2 Würmer". This is would is in the de.po file, too. Opening this file with Scite shows the translation with the right german characters. The UTF-8 format of the po-file is recognized by Scite, too. What could be wrong? Govinda rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org schrieb am 10.08.05 12:58:56: Govinda Pfister wrote: > Hello Sascha, > > great work with that I18N-Guide. > > I tried this out yesterday and nearly everything works fine for me. > > I just have one problem: > > The command "rake gettext" seems to generate the po-files with > ascii-encoding not utf-8. > > At least if I try to open these po-files with poEdit I get the error > message "cannot convert from encoding ascii". > > Furthermore if use german characters in the like ''ß'' or ''ü'' in the > de.po-file I get an error message when the rails environment is loaded. > > "./script/../config/../vendor/gems/ri18n-0.0.3/lib/ri18n/po.rb:22:in > `iconv'':Iconv::IllegalSequence: "ß %i einen Wurm"..." > > What is wrong? Help is as always very appreciated! Yes, that was my mistake. I forgot to specify the $KCODE in the rake task. ri18n decides which charset to use by looking at it. So this is how it is supposed to look: task :gettext do $:.unshift ''vendor/ri18n/lib'' # don''t forget the $KCODE $KCODE = ''u'' require ''gettext'' require ''i18nservice'' I18nService.instance.po_dir = File.dirname(__FILE__) + ''/locale'' desc ''Run the ri18n harvester on this application'' Rake::GettextTask.new do |t| # add all desired langues here t.new_langs = [''de'', ''fr''] # add all desired paths here t.source_files = [''{lib,app,components}/**/*.r{b,html,xml}''] t.verbose = true end end Sascha Ebach _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Michael Schuerig
2005-Aug-10 12:41 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
On Wednesday 10 August 2005 14:28, Govinda Pfister wrote:> now I do not get the error message any more, but an irb session (the > rails console) shows that something is still not working properly: > irb session> Ich aß 2 Würmer> The translation should be "Ich aß 2 Würmer".Is your console set to display UTF-8 correctly? Michael -- Michael Schuerig Most people would rather die than think. mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org In fact, they do. http://www.schuerig.de/michael/ --Bertrand Russell
Sascha Ebach
2005-Aug-10 12:43 UTC
Re: 10 Easy Steps To Make Your Rails Apps Multilingual (I18N)
Govinda Pfister wrote:> Hello, > > now I do not get the error message any more, but an irb session (the > rails console) shows that something is still not working properly: > > irb session > --------- > > >> ente = Duck.new > => #<Duck:0x83e79a8> > >> ente.eat_worms > Ich aß 0 Würmer > Ich aß 1 einen Wurm > Ich aß 2 Würmer > Ich aß 3 Würmer > Ich aß 4 Würmer > => 0 > >> > > The translation should be "Ich aß 2 Würmer". > > This is would is in the de.po file, too. Opening this file with Scite > shows the translation with the right german characters. The UTF-8 format > of the po-file is recognized by Scite, too. > > What could be wrong?Nothing is wrong. Your console doesn''t support unicode output. So internally everything is correct, but the display on the console doesn''t know what to do with those characters. Sascha