From 9f030acf22696a476578e9ccde9984fa1b86f02c Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 3 Feb 2009 01:08:37 +0100 Subject: regenerate guides HTML --- railties/doc/guides/html/i18n.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/doc/guides/html/i18n.html') diff --git a/railties/doc/guides/html/i18n.html b/railties/doc/guides/html/i18n.html index b0d52c0ff5..8deee39779 100644 --- a/railties/doc/guides/html/i18n.html +++ b/railties/doc/guides/html/i18n.html @@ -504,7 +504,7 @@ private def extract_locale_from_accept_language_header request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first end -

Of course, in production environment you would need much robust code, and could use a plugin such as Iaian Hecker’s http_accept_language.

+

Of course, in production environment you would need much robust code, and could use a plugin such as Iaian Hecker’s http_accept_language or even Rack middleware such as Ryan Tomayko’s locale.

2.6.2. Using GeoIP (or similar) database

Another way of choosing the locale from client’s information would be to use a database for mapping client IP to region, such as GeoIP Lite Country. The mechanics of the code would be very similar to the code above — you would need to query database for user’s IP, and lookup your preffered locale for the country/region/city returned.

2.6.3. User profile

@@ -598,6 +598,7 @@ pirate: You need to restart the server when you add new locale files. +

You may use YAML (.yml) or plain Ruby (.rb) files for storing your translations in SimpleStore. YAML is the preffered option among Rails developers, has one big disadvantage, though. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. Ruby files will crash your application on first request, so you may easily find what’s wrong. (If you encounter any "weird issues" with YAML dictionaries, try putting the relevant portion of your dictionary into Ruby file.)

3.2. Adding Date/Time formats

OK! Now let’s add a timestamp to the view, so we can demo the date/time localization feature as well. To localize the time format you pass the Time object to I18n.l or (preferably) use Rails' #l helper. You can pick a format by passing the :format option — by default the :default format is used.

-- cgit v1.2.3