Sam wrote "...distinction between translating the application (the text in the views) and the data models. Globalize will throw these together in the same basket, but I'm not convinced this is an ideal solution..."
Globalize does not *require* that you translate views with DB-backed strings. You can also use per-language template files. Chris Hapgood Skype: chris.hapgood -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, November 16, 2007 05:39 To: railsi18n-discussion@rubyforge.org Subject: Railsi18n-discussion Digest, Vol 17, Issue 1 Send Railsi18n-discussion mailing list submissions to railsi18n-discussion@rubyforge.org To subscribe or unsubscribe via the World Wide Web, visit http://rubyforge.org/mailman/listinfo/railsi18n-discussion or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Railsi18n-discussion digest..." Today's Topics: 1. unicode categories in regexps? (Jonathan Rochkind) 2. Re: Gettext's Locale class in application namespace (Samuel Lown) 3. Dates in Gettext (Samuel Lown) 4. Re: Ruby-Gettext and date/time? (Samuel Lown) 5. Re: Dates in Gettext (Samuel Lown) 6. Re: Dates in Gettext (Samuel Lown) 7. internationalization options (Chuck R.) 8. Re: internationalization options (Samuel Lown) 9. Re: Legacy ISO-8859-1 MSSQL db and UTF8 rails app (Julio Damasceno) 10. Problem with image_tag (Mark Chandler) 11. Re: Problem with image_tag (Mark Chandler) 12. Re: removing accents from sentences (ex: url creations) - wh (Johan Stille) 13. Re: removing accents from sentences (ex: url creations) - wh (Patrick Hall) ---------------------------------------------------------------------- Message: 1 Date: Thu, 25 Oct 2007 19:30:48 +0200 From: Jonathan Rochkind <[EMAIL PROTECTED]> Subject: [Rails I18n] unicode categories in regexps? To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Is there anything for ruby that will give me access to unicode character categories in a regexp like function? For instance, say I want to replace all punctuation with a space, in a unicode-friendly way that will work with any langauges script in unicode. Unicode does provide character classes to make this possible, and other languages built in regexp features support that... but do I have any options in ruby? Thanks, Jonathan -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 2 Date: Sun, 28 Oct 2007 11:58:25 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Gettext's Locale class in application namespace To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 For the moment, I've converted my own Locale model into SystemLocale so that it does not conflict with the interests of Gettext. Not the ideal situation IMHO, but it will suffice. Cheers, sam -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 3 Date: Wed, 31 Oct 2007 12:25:10 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: [Rails I18n] Dates in Gettext To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Hi All, It comes up quite a lot, and after much searching, I've not been able to find a solution to handling dates in Gettext that I actually liked. Overriding array constants inside various libraries and expecting things to work didn't do it for me. So I made my own solution. The attached gettext_date.rb file is a *preview* to try and get a bit of feedback about the viability of this approach. Dates are messy, so I'm expecting that my solution does not cover all the possible exceptions to the basic rules I've defined. It's primarily designed for Ruby on Rails, but should work with any ruby app, although the TimeExtensions is unnecessary. To install, copy the gettext_date.rb file to your /lib directory, and add the following line to your environment.rb: require 'lib/gettext_date' Assuming you have every other part of Rails setup for Gettext, and you're .po files contain the translated month and day names, it should "just work". There is no need to add the .localize call to all your time methods, and you can stick with the standard strftime calls. Its also designed so that Time.now.to_s(:rfc822) or similar RFC calls will use the standard ruby strftime method, and remain in english as the standard requires. The key advantage with my approach, is that if your application does not use English as your native language, the GettextDate::Conversions class can be overwritten with the names in the other language, therefore removing any confusing language inconsistencies for the translators. I'll set up a web site as soon as possible with more details, but I'd love to get some feedback! At least now Gettext fans don't have to be jealous of the Globalize crowd :-) Cheers, sam Attachments: http://www.ruby-forum.com/attachment/821/gettext_date.rb -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 4 Date: Wed, 31 Oct 2007 12:34:18 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Ruby-Gettext and date/time? To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Christian Johansen wrote: > How can I have localized dates and times using Ruby-Gettext? You can now! http://www.ruby-forum.com/topic/129944 sam -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 5 Date: Wed, 31 Oct 2007 14:01:56 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Dates in Gettext To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Forgot to mention, the _( ) method needs to be accessible to the GettextDate library, a quick fix for this is to add the following in /config/environment.rb just after the 'gettext/rails' require. include GetText::Rails bindtextdomain('DOMAIN') require 'lib/gettext_date' DOMAIN should be replaced with your current application domain. This approach provides the _( ) method for everything, and duplicates the init_gettext call, which is a bit lame, so I'll work on doing it another way. Good for testing though! Cheers, sam -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 6 Date: Wed, 31 Oct 2007 14:41:19 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Dates in Gettext To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Samuel Lown wrote: > > include GetText::Rails > bindtextdomain('DOMAIN') > require 'lib/gettext_date' > Scrap that, use this version instead, which automatically extends the ActionController::Base with a version of init_gettext that adds the text domain to the Conversions: http://www.samlown.com/uploads/ruby/gettext_date.rb sam. -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 7 Date: Fri, 2 Nov 2007 21:20:52 +0100 From: "Chuck R." <[EMAIL PROTECTED]> Subject: [Rails I18n] internationalization options To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Hi, I'm new to ruby and rails. I need support for for localized pages, pages with multilingual content, international date/time formats, and calendar and time zone calculations. Initially, I asked someone on the ICU project <http://www.icu-project.org/> and they directed me to ICU4R <http://icu4r.rubyforge.org/>. I thought that this was my solution until I scrolled down and found this comment: "The code is slow and inefficient yet, is still highly experimental, so can have many security and memory leaks, bugs, inconsistent documentation, incomplete test suite. Use it at your own risk." Next, I found this link: http://wiki.rubyonrails.org/rails/pages/InternationalizationComparison Globalize <http://www.globalize-rails.org/globalize/> looks very up-to-date and well supported. And every time I ask people about internationalization options, they seem to either mention Globalize or say that they don't know. Is Globalize the most widely used option? Do people on this list recommend Globalize or other options? thanks, Chuck -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 8 Date: Mon, 5 Nov 2007 10:21:08 +0100 From: Samuel Lown <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] internationalization options To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Hi Chuck, Chuck R. wrote: > > Is Globalize the most widely used option? Do people on this list > recommend Globalize or other options? > Globalize is probably is one of the most widely used solutions for internationalisation in Rails, given, as you say, it is well looked after and provides a very easy solution to integrate with your Rails project. However, I suspect most people are slightly suspicious about the way translations are handled, everything in Globalize is stored in three tables, including one master table that contains all of your translations in every language. If your into wanting to make DB access as minimal and efficient as possible, like me, then this may or may not ring bells. Personally, I now use Gettext for all of my web application texts, as its very mature and while initially it takes a bit of understanding, it offers the most complete solutions for handling strings. Having said that, I did use Globalize in one major project and it works great! One thing you should bare in mind, is the distinction between translating the application (the text in the views) and the data models. Globalize will throw these together in the same basket, but I'm not convinced this is an ideal solution. Checkout my plugin 'translate_columns' for a description of the problems and a solution that I came up with: http://samlown.com/page/RailsTranslateColumnsPluginReadme This only handles models, so you'd need to find another solution, such as globalize or gettext, for your views. I18n is quite complex, and requires a bit of thought to implement well, but stick with it, its worth the effort! Cheers, Sam -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 9 Date: Mon, 5 Nov 2007 16:39:27 +0100 From: Julio Damasceno <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Legacy ISO-8859-1 MSSQL db and UTF8 rails app To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Tom Bak wrote: > I solved my problem with own plugin: > > recode_legacy_database :from => "ISO-8859-1", :to => "UTF-8" > > Which translates fields in models on read and before write to database. > > Cheers, > Tomasz Tom, How is the usage of this plugin? I have to run this command manual? When I have to put this code? Thanks, Julio -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 10 Date: Sat, 10 Nov 2007 02:11:15 +0100 From: Mark Chandler <[EMAIL PROTECTED]> Subject: [Rails I18n] Problem with image_tag To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 I've been following a tutorial for Rails that goes through uploading images directly to databases. The problem is that using image_tag keeps automatically appending .png to the end of the address. /classified/image/9 displays the image correctly, but the image /classified/image/9.png keeps being added to the view instead. Thanks in advance! classified_controller.rb: ... def image @image = Classified.find(params[:id]) send_data @image.picture, :filename => "pic.jpg", :type => @image.content_type, :disposition => "inline" end ... show.rhtml: ... <% unless @classified.picture.blank? %> <%= image_tag(url_for({:action => 'image', :id => @classified.id})) -%> <% end %> ... -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 11 Date: Sat, 10 Nov 2007 02:12:21 +0100 From: Mark Chandler <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] Problem with image_tag To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 Just realized I posted this in the wrong forum! Please delete! -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 12 Date: Fri, 16 Nov 2007 11:23:39 +0100 From: Johan Stille <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] removing accents from sentences (ex: url creations) - wh To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=utf-8 I wrote this extension to String a long time ago. I think it does what you want. require 'iconv' class String def pretty_url Iconv.iconv("ASCII//IGNORE//TRANSLIT", "UTF-8", self).join.sanitize rescue self.sanitize end def sanitize self.gsub(/[^a-z._0-9 -]/i, "").tr(".", "_").gsub(/(\s+)/, "_").dasherize.downcase end end Thibaut Barr?re wrote: > Hi! > > I could not find it so far - but maybe rails i18n is the right list for > that > question: is there something already available somewhere in the ruby > space > to remove accents and other diacritics from a string ? (like: > translation > ?ph?m?re to ephemere, etc) > > I've seen the mephisto PermalinkFu trick (iconv from utf-8 to > ascii//ignore//translit) but it doesn't work on my workstation. > > I've attached DiacriticsFu which I wrote and is working fine for me - > I'd be > happy to find something cleaner, cross-platform, and which does not rely > on > Rails like this implementation (it would most likely work with unicode > hacks) > > any hint, comment, link, idea ? > > cheers > > Thibaut -- Posted via http://www.ruby-forum.com/. ------------------------------ Message: 13 Date: Fri, 16 Nov 2007 05:31:45 -0500 From: "Patrick Hall" <[EMAIL PROTECTED]> Subject: Re: [Rails I18n] removing accents from sentences (ex: url creations) - wh To: railsi18n-discussion@rubyforge.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=UTF-8 Hi, On Nov 16, 2007 5:23 AM, Johan Stille <[EMAIL PROTECTED]> wrote: > require 'iconv' > > class String > def pretty_url > Iconv.iconv("ASCII//IGNORE//TRANSLIT", "UTF-8", self).join.sanitize > rescue > self.sanitize > end > > def sanitize > self.gsub(/[^a-z._0-9 -]/i, "").tr(".", "_").gsub(/(\s+)/, "_").dasherize.downcase > end > end There's a missing dasherize method here, no? -Pat ------------------------------ _______________________________________________ Railsi18n-discussion mailing list Railsi18n-discussion@rubyforge.org http://rubyforge.org/mailman/listinfo/railsi18n-discussion End of Railsi18n-discussion Digest, Vol 17, Issue 1 *************************************************** No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.33/1133 - Release Date: 15/11/2007 20:57 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.15.33/1133 - Release Date: 15/11/2007 20:57 _______________________________________________ Railsi18n-discussion mailing list Railsi18n-discussion@rubyforge.org http://rubyforge.org/mailman/listinfo/railsi18n-discussion