Welcome Guest | Login

Problem with gettext and rails app

Hi,

We use the gettext gem intensively since our app is planned to support 5 or 6 languages.

We just started seeing (or at least just noticed) a problem running our app on hosting rails. Some of the gettexted strings (those we use with variable substitution) appear to be cached! This does not happen in our development environment, even with the rails environment set to production.

The bottom line is that once a gettext string translation and asignment is done, it appears to be frozen. For example, the first person to log into the app gets a message saying "Welcome John Smith blah blah" All future logins get the same welcome message even though their first name ans last name should be substituted into the string.

Here is some relevant code snippets ...

In the gettext po file:
msgid "Welcome_john_doe,_you_are_logged_in"
msgstr "Welcome %0 %1, you are logged in !"

In the login controller:
flash[:info] = _('Welcome_john_doe,_you_are_logged_in').replace_variables([@user.first_name, @user.last_name])

Any ideas?

2008-03-13 07:34 AM

Are you using the gettext gem frozen in your app?  We don't do anything special/on purpose to cache it - however for php it looks like the only way to flush the cache is to restart apache.

Thus, you may think about using a "a date or version number in the gettext domain string" from this page

2008-03-13 01:59 PM

William,

Hi, thanks for the reply. No, we are currently not running the gettext gem frozen into our app. But we did notice that the version we are developing with is 1.90 (must have upgraded to it when we updated to rails 2.0.2) and the version on hosting rails is 1.10.

Maybe there are some issues ... Can you install 1.90 on the server for us? Can I do it myself - how?

Thanks.

2008-03-14 11:18 AM


I've installed the gettext gem version 1.90 on the server now. Also you can follow our tutorial below to install and freeze your own rubygems.
------
http://www.hostingrails.com/forums/wiki_thread/2

2008-03-14 05:58 PM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!