From olaf.spaarmann at gmail.com Wed Aug 5 13:30:11 2009 From: olaf.spaarmann at gmail.com (Olaf S.) Date: Wed, 5 Aug 2009 19:30:11 +0200 Subject: [Rails I18n] Very strange problem with Gettext and Haml Message-ID: <2a86ba5484349f785ccdc034058bf44f@ruby-forum.com> Hi, I'm on Rails 2.3.3 and using Haml 2.0.9 for my templates and Gettext-Rails 2.0.4 for the translation. Haml works like a charm and gettext is also working like it should. But I cant get Gettext to parse Haml Files when using "rake updatepo". I created a custom parser like this: # lib/haml_parser.rb require 'gettext_rails/tools' require 'haml' # Haml gettext parser module HamlParser module_function def target?(file) File.extname(file) == ".haml" end def parse(file, ary = []) haml = Haml::Engine.new(IO.readlines(file).join) code = haml.precompiled.split(/$/) GetText::RubyParser.parse_lines(file, code, ary) end end GetText::RGetText.add_parser(HamlParser) My Rakefile looks like this: # Rakefile require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' desc "Create mo-files for L10n" task :makemo do require 'gettext_rails/tools' GetText.create_mofiles(true) #(true, "po", "locale") end desc "Update pot/po files to match new version." task :updatepo do require 'gettext_rails/tools' require 'haml_parser' MY_APP_TEXT_DOMAIN = "APP" MY_APP_VERSION = "APP 1.1.0" GetText.update_pofiles(MY_APP_TEXT_DOMAIN, Dir.glob("{app,lib}/**/*.{rb,rhtml,html.erb,haml,html.haml,rjs}"), MY_APP_VERSION) end This follows the known approach for parsing Haml files ( http://www.paulgillard.me.uk/2008/3/8/rails-haml-and-gettext ). The problem: No MessageIds are recognized from my Haml files. I checked with "puts" in the Haml-Parser if it tried the right files, could parse them and so on. Everything seemed to be fine, it just recognize anything and always returned only the already found msgids and for the Haml file an empty Array. The strange thing: When I enter this in my console, everything works: $$ script/console Loading development environment (Rails 2.3.3) >> require 'gettext_rails/tools' => [] >> require 'haml' => [] >> file = "app/views/sessions/new.haml" => "app/views/sessions/new.haml" >> haml = Haml::Engine.new(IO.readlines(file).join) => #> code = haml.precompiled.split(/$/) => [" content_for :head do;", "\nhaml_temp = stylesheet_link [...] >> GetText::RubyParser.parse_lines(file, code, []) => [["Login", "app/views/sessions/new.haml:4"], [...] As you can see everything works here (I left out the long returns). I'm kind of freaking out why this isn't the case in my Rake Task. Anyone has an idea? You would really make me a happy Nerd! Thanks! -- Posted via http://www.ruby-forum.com/. From antoine at biskinito.net Tue Aug 11 04:26:54 2009 From: antoine at biskinito.net (Antoine Antoine) Date: Tue, 11 Aug 2009 10:26:54 +0200 Subject: [Rails I18n] Translating missing for I18n in models after upgrading gem Message-ID: Hi everyone, I deployed yesterday a new version of my website. For some features, I had to upgrade rubygems to 1.3.1 version. Here is my gem env : RubyGems Environment: - RUBYGEMS VERSION: 1.3.1 - RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111) [i486-linux] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS PLATFORMS: - ruby - x86-linux - GEM PATHS: - /usr/lib/ruby/gems/1.8 - /home/tableonline/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://gems.rubyforge.org/ Version of rails is 2.2.2 Path seems to be ok, as all my gems are there. But since then (and i really don't understand the link), I18n ONLY IN MODELS rb files is not working and I get the "Translation missing: en" message for variables in those files. The weird stuff is that my locale is fr (and seems to work as the rest of the website is correctly translated). Even more strange, in development environment (on my mac) everything is working with the same versions. I tried changing locale, upgrading en.yml with french values, nothing changed... Any clue of what is happening ? Thanks a lot. -- Posted via http://www.ruby-forum.com/. From antoine at biskinito.net Tue Aug 11 07:38:59 2009 From: antoine at biskinito.net (Antoine Antoine) Date: Tue, 11 Aug 2009 13:38:59 +0200 Subject: [Rails I18n] Translating missing for I18n in models after upgrading gem In-Reply-To: References: Message-ID: <09b5753d958e89f22354e43e214f7862@ruby-forum.com> This now more precise : only constants values in models are not working. But I still don't understand why. Moreover, if I create the en.yml identical to fr (with en at the beginning of the file), the problem remains the same. -- Posted via http://www.ruby-forum.com/. From arthur at pixopixel.com Fri Aug 21 06:23:47 2009 From: arthur at pixopixel.com (Arthur Chan) Date: Fri, 21 Aug 2009 12:23:47 +0200 Subject: [Rails I18n] Translate Pages Message-ID: <4e682aae9bc5d9174605b78ad0e76e77@ruby-forum.com> Hi Guys, PROBLEMS: Our website supports both Chinese and English. We found that there are many cases need different ways of translation. a. For the views, we can translate words easily using the "_('hello world')" functions. b. For the static pages, we are using the: /contact_us.html (for english) /locale/zh_TW/contact_us.html (for chinese) Nevertheless, there are two more cases I don't know how to translate way are better: c. Error page: I don't know whether the "_()" function works d. Server is down page: when Rails is down, the lighttd may redirect to another static page. METHODS: How should we translate these four cases? I am thinking whether we should load the English and then translate using AJAX (or push the languages content to client and load it using Javascript)? Thanks! Arthur -- Posted via http://www.ruby-forum.com/. From rubyforum at thisisnotmyrealemail.com Tue Aug 25 15:17:58 2009 From: rubyforum at thisisnotmyrealemail.com (Joao Silva) Date: Tue, 25 Aug 2009 21:17:58 +0200 Subject: [Rails I18n] Problem with Iconv Message-ID: <12959fac7c1cf706bcdff97837d46f7a@ruby-forum.com> Hello! Here is my code: require 'iconv' result = Iconv.iconv('ascii//translit//IGNORE', 'utf-8', "za???? g??l? ja??") puts result.to_s.gsub(/[^\x00-\x7F]+/, '').gsub(/[^\w_ \-]+/i, '') Result (Mac OS X Leopard): code/Rails/x[master]% port list | grep iconv libticonv @1.1.0 math/libticonv p5-text-iconv @1.4 perl/p5-text-iconv libiconv @1.12 textproc/libiconv code/Rails/x[master]% ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9] code/Rails/x[master]% ruby test.rb zazolc gesla jazn This is what I want, but on my production (Ubuntu) machine i get much different result: rails at li103-32:~$ dpkg -l | grep iconv ii libtext-iconv-perl 1.7-1build1 converts between character sets in Perl rails at li103-32:~$ ruby -v ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux] Ruby Enterprise Edition 20090610 rails at li103-32:~$ ruby test.rb za gl ja What may causing this error? Maybe i need to install additional packages? -- Posted via http://www.ruby-forum.com/.