From yaohan.chen at gmail.com Mon Jun 2 19:34:09 2008 From: yaohan.chen at gmail.com (Yaohan Chen) Date: Mon, 2 Jun 2008 19:34:09 -0400 Subject: [gettext-u-en] Utility to semi-automatically add _( ) to ruby files Message-ID: <200806021934.10260.yaohan.chen@gmail.com> Hello, I find putting _( ) around strings in already written ruby programs a tedious process, so I wrote a program to help me do it. "texter" looks for strings enclosed in ' ' or " " in the input file, displays each string highlighted in the middle of its surrounding text, and asks you whether to put _( ) around it. If the string contains embedded expressions like "hello #{name}", it rewrites it as _("hello %{name}") % {:name => name}, after asking you to specify the label for the expression. It then also asks you whether to parenthesize this expression, to avoid parsing error. As you probably suspect, texter isn't able to deal with all Ruby syntax correctly yet. Currently it does not consider %( ), here-doc as strings, and quotes inside them as well as regexp are treated as string delimiters. However, it is still in development; I would be grateful if you try it, give feedback or contribute. http://github.com/hagabaka/texter/tree git://github.com/hagabaka/texter.git Yaohan Chen From yaohan.chen at gmail.com Thu Jun 5 18:13:55 2008 From: yaohan.chen at gmail.com (Yaohan Chen) Date: Thu, 5 Jun 2008 18:13:55 -0400 Subject: [gettext-u-en] empty output from msgmerge should not be interpreted as error Message-ID: <200806051813.56222.yaohan.chen@gmail.com> Hello, I noticed that if a ruby file has no translatable strings, and a pot file is created from it, then running update_pofiles again will cause an error with such output: po/file.pot . done. Failed to merge with po/file.pot New .pot was copied to tmp.pot~ Check these po/pot-files. It may have syntax errors or something wrong. The cause of this is that GNU gettext's msgmerge (0.17) seems to never output anything when the def.po and ref.pot files are identical. But if you supply a switch -o output.po, the output.po file will be untouched. Also msgmerge prints ". done." in stderr as usually, without any error message. I think this suggests that empty output from msgmerge does not indicate an error in the pot file, only that no change is needed. Following is my proposed patch. ? msgmerge-empty-output.diff Index: lib/gettext/utils.rb =================================================================== RCS file: /var/cvs/gettext/gettext/lib/gettext/utils.rb,v retrieving revision 1.7 diff -u -r1.7 utils.rb --- lib/gettext/utils.rb 6 May 2008 17:36:43 -0000 1.7 +++ lib/gettext/utils.rb 5 Jun 2008 22:06:54 -0000 @@ -60,13 +60,14 @@ cont = io.read end end - if cont.empty? + unless $?.success? failed_filename = refpo + "~" FileUtils.cp(refpo, failed_filename) $stderr.puts _("Failed to merge with %{defpo}") % {:defpo => defpo} $stderr.puts _("New .pot was copied to %{failed_filename}") %{:failed_filename => failed_filename} raise _("Check these po/pot-files. It may have syntax errors or something wrong.") else + cont = File.read(defpo) if cont.empty? cont.sub!(/(Project-Id-Version\:).*$/, "\\1 #{app_version}\\n\"") File.open(defpo, "w") do |out| out.write(cont) From sabrebox2000-code at yahoo.com.sg Mon Jun 9 06:59:21 2008 From: sabrebox2000-code at yahoo.com.sg (Sean Tan) Date: Mon, 09 Jun 2008 18:59:21 +0800 Subject: [gettext-u-en] Untranslated text appears under heavy load In-Reply-To: <200806051813.56222.yaohan.chen@gmail.com> References: <200806051813.56222.yaohan.chen@gmail.com> Message-ID: <484D0D09.20706@yahoo.com.sg> Hi, I'm currently using Rails 2.0.2 and gettext gems 1.91.0. I'm currently experiencing issues with my website when the load is higher. Random untranslated text appears on the page. It is not the entire page that is untranslated, only 1 part or 2. And the parts are random and it happens through out the website. Most of the time, upon refreshing the page, the page becomes fully translated again. I added the following to my app to enable gettext. Previously when I'm using Rails 1.2.6 and gettext 1.10.0, there are no such issues. -------- environment.rb require 'gettext/rails' application.rb class ApplicationController < ActionController::Base before_init_gettext :set_my_locale init_gettext 'gameportal' def set_my_locale(new_locale = nil) locale = new_locale || params["locale"] || cookies[:locale] || 'en_US' @locale = LOCALES_FETCH.from_key(locale).nil? ? LOCALES_FETCH.default_locale : locale cookies[:locale] = @locale set_locale(@locale) end end -------- Can anyone help me? Thank you very much! -- Sean