From thefkingfrench at gmail.com Sun May 3 13:01:21 2009 From: thefkingfrench at gmail.com (The Man) Date: Sun, 3 May 2009 19:01:21 +0200 Subject: [Rails I18n] uninitialized constant Iconv Message-ID: <94b1d96b8255913d11ebf93739bcade8@ruby-forum.com> Hi there, I'm having an issue with a RoR website : when trying to save a text change into the database i get the error below Strange thing is that i imported the database from production where it is working well, under mysql on both development and production... After being gone through some reasearch, i found this is most likely because of an encoding mismatch. But the encoding in the database.yml is the same in production and dev as well... Any ideas ? Attachments: http://www.ruby-forum.com/attachment/3646/iconv_error.txt -- Posted via http://www.ruby-forum.com/. From winterheat at gmail.com Sat May 9 08:03:57 2009 From: winterheat at gmail.com (Jian Lin) Date: Sat, 9 May 2009 14:03:57 +0200 Subject: [Rails I18n] converting UTF-8 to entities like 剛 Message-ID: <82dc1cf06a6fef27c14a1acb227a2ca6@ruby-forum.com> I was trying to convert UTF-8 content into a series of entities like 剛 so that whatever the page encoding is, the characters would show... so I used something like this: <% begin t = '' s = Iconv.conv("UTF-32", "UTF-8", some_utf8_string) s.scan(/(.)(.)(.)(.)/) do |b1, b2, b3, b4| t += ("&#x" + "%02X" % b3.ord) + ("%02X" % b4.ord) + ";" end rescue => details t = "exception " + details end %> <%= t %> but some characters get converted, and some don't. Is it true that (.)(.)(.)(.) will not necessarily match 4 bytes at a time? At first, I was going to use s = Iconv.conv("UTF-16", "UTF-8", some_utf8_string) but then i found that utf-16 is also variable length... so I used UTF-32 instead which is fixed length. The UTF-8 string I have is just the Basic Plane... so should be all in the 0x0000 to 0xFFFF range in unicode. -- Posted via http://www.ruby-forum.com/. From winterheat at gmail.com Sat May 9 08:16:12 2009 From: winterheat at gmail.com (Jian Lin) Date: Sat, 9 May 2009 14:16:12 +0200 Subject: [Rails I18n] converting UTF-8 to entities like 剛 In-Reply-To: <82dc1cf06a6fef27c14a1acb227a2ca6@ruby-forum.com> References: <82dc1cf06a6fef27c14a1acb227a2ca6@ruby-forum.com> Message-ID: <03f920af59298e98e1941b372a13f7ca@ruby-forum.com> by the way, this works: but i am sure there are more elegant solutions. <% begin t = '' s = Iconv.conv("UTF-32", "UTF-8", some_utf8_string) (s.length / 4).times do |i| b3 = s[i*4 + 2] b4 = s[i*4 + 3] t += ("&#x" + "%02X" % b3) + ("%02X" % b4) + ";" end rescue => details t = "exception " + details end %> <%= t %> -- Posted via http://www.ruby-forum.com/. From damick at netronix.be Mon May 11 16:16:20 2009 From: damick at netronix.be (Michael Rigart) Date: Mon, 11 May 2009 22:16:20 +0200 Subject: [Rails I18n] Multilingual model content Message-ID: Hi I'm looking for some insight in a small problem I have. I need multilingual input in my models. Lets say you have a Product model. That product contains title, description and price. The price is allways the same, but the title and description need to be inputted in diffrent languages. I have used the I18n framework build in Rails, so no external plugin and I would like to keep it that way. One idea I was playing with is the following model build: Product ------- id price ProductI18n ----------- id product_id language -> I18n code like EN, BE, FR title description But how do I link those 2 together, so that I can show the product details in the current user language? Is there a way to pass a variable trough the Product association like this: has_one :product_language, :class_name => :product_i18n, :conditions => "language = users_current_language_code" I know I'm on the good track, but I know I'm missing something. thank you for the insight -- Posted via http://www.ruby-forum.com/. From wolfram at arnold.name Wed May 20 03:54:23 2009 From: wolfram at arnold.name (Wolfram Arnold) Date: Wed, 20 May 2009 09:54:23 +0200 Subject: [Rails I18n] Multilingual model content In-Reply-To: References: Message-ID: Take a look at the globalize 2 plugin on github: http://github.com/joshmh/globalize2/tree/master It covers model translation like you want to do and is recommended by the author of the I18n Rails guide: http://guides.rubyonrails.org/i18n.html -- Posted via http://www.ruby-forum.com/. From wolfram at arnold.name Wed May 20 04:02:19 2009 From: wolfram at arnold.name (Wolfram Arnold) Date: Wed, 20 May 2009 10:02:19 +0200 Subject: [Rails I18n] UTF8 vs Latin1 String comparison in MySQL? Message-ID: I'm running into a surprising twist in MySql string compare. Try this: select "Am?rica" = "America"; +------------------------+ | "Am?rica" = "America" | +------------------------+ | 1 | +------------------------+ My db and client are in UTF8: show variables like "%character%"; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ MySql lets you force an encoding on a per string basis, if you try this: _utf8"xxx" the string is in UTF8, of _latin1"xxx" then "xxx" is in Latin 1. Here is what's puzzling me: select _latin1"Am?rica" = _latin1"America"; +--------------------------------------+ | _latin1"Am?rica" = _latin1"America" | +--------------------------------------+ | 0 | +--------------------------------------+ vs select _utf8"Am?rica" = _utf8"America"; +----------------------------------+ | _utf8"Am?rica" = _utf8"America" | +----------------------------------+ | 1 | +----------------------------------+ Why does it think the UTF8 strings are the same when the Latin1 ones are not??? What am I not getting? Thanks! Wolf -- Posted via http://www.ruby-forum.com/. From sarah at ultrasaurus.com Wed May 20 08:55:50 2009 From: sarah at ultrasaurus.com (Sarah Allen) Date: Wed, 20 May 2009 14:55:50 +0200 Subject: [Rails I18n] UTF8 vs Latin1 String comparison in MySQL? In-Reply-To: References: Message-ID: <67b62190e00d05bcba11e3c9f15971f6@ruby-forum.com> Wolfram Arnold wrote: > I'm running into a surprising twist in MySql string compare. > > Try this: > > select "Am?rica" = "America"; > +------------------------+ > | "Am?rica" = "America" | > +------------------------+ > | 1 | > +------------------------+ I looked into this a bit this morning. It seems that string comparison is affected by "collation" not charset. The default utf8 collation yields the unexpected result: mysql> SHOW VARIABLES LIKE '%collat%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+ 3 rows in set (0.00 sec) mysql> select "Am?rica" = "America"; +------------------------+ | "Am?rica" = "America" | +------------------------+ | 1 | +------------------------+ 1 row in set (0.00 sec) But if I change the collation to utf8_bin, the strings compare as unequal: mysql> set collation='utf8_bin'; Query OK, 0 rows affected (0.04 sec) mysql> set collation_server='utf8_bin'; Query OK, 0 rows affected (0.00 sec) mysql> set collation_database='utf8_bin'; Query OK, 0 rows affected (0.00 sec) mysql> SHOW VARIABLES LIKE '%collat%'; +----------------------+----------+ | Variable_name | Value | +----------------------+----------+ | collation_connection | utf8_bin | | collation_database | utf8_bin | | collation_server | utf8_bin | +----------------------+----------+ 3 rows in set (0.00 sec) mysql> select "Am?rica" = "America";; +------------------------+ | "Am?rica" = "America" | +------------------------+ | 0 | +------------------------+ 1 row in set (0.00 sec) I'm a bit confused myself about how utf8_general_ci could sort effectively if '?' equals 'e' since users would expect all the like characters to group together and why this collation would be useful; nor do I understand if there are other implications to using utf8_bin collation. There is a nicely written report on Unicode collation here: http://www.unicode.org/unicode/reports/tr10/ Sarah -- Posted via http://www.ruby-forum.com/. From dfl_maradentro at yahoo.es Wed May 20 17:51:48 2009 From: dfl_maradentro at yahoo.es (Damaris Fuentes) Date: Wed, 20 May 2009 23:51:48 +0200 Subject: [Rails I18n] Data in database in multiple languages (newbie) Message-ID: <1ef054365840896829743090732601f2@ruby-forum.com> Hi you all, I have an application where my data in the database is stored in one language (Spanish), where a record has "name", "desc", etc. However, I also have to show the user the data in English. I've read some stuff there but I don't really know if Rails have something (a plugin) which can make this task easy or it's better to do it on my own... Just asking for some guidance. -- Posted via http://www.ruby-forum.com/. From shameermelethil at gmail.com Sat May 23 01:18:22 2009 From: shameermelethil at gmail.com (Shameer Melethil) Date: Sat, 23 May 2009 07:18:22 +0200 Subject: [Rails I18n] File upload using form_remote tag Message-ID: <6dab03b86996458486c69ad62aba05cb@ruby-forum.com> Is it possible to upload files using form_remote_tag in rails 2.3.2. If please explain me the steps to follow. Thanks in advance Shameer Melethil -- Posted via http://www.ruby-forum.com/. From dgwauss at web.de Sun May 24 10:54:30 2009 From: dgwauss at web.de (=?utf-8?Q?Herman_M=c3=bcller?=) Date: Sun, 24 May 2009 16:54:30 +0200 Subject: [Rails I18n] text_field as date Message-ID: <0a3b892d86c848c19e40ebfc133df882@ruby-forum.com> Hi Ruby Comuniy! I have implemented i18n and when I set the locale to "de" everthing works fine, I mean date_select shows the german date-format. The problem is, that I want to use a text_field for date-input like: <%= f.text_field :date_test %> But when I open the edit.html.erb the date-output is not the "de-fromat" like 31.12.2008 it is the database format like 2008-12-31. I tried something like <%= l f.text_field :date_test %> but then I get this error message: "Object must be a Date, DateTime or Time object" Do somebody knows a solution? Thanks ahead!!! Regs Hermann -- Posted via http://www.ruby-forum.com/. From shubhinetwork1 at gmail.com Sat May 30 13:42:50 2009 From: shubhinetwork1 at gmail.com (Mark Jones) Date: Sat, 30 May 2009 19:42:50 +0200 Subject: [Rails I18n] cars Message-ID: <708388003194c213f313aac8de322f9b@ruby-forum.com> hiii guys When Ford introduced the Sync infotainment system in 2007, it was truly revolutionary and available only in select vehicles. On May 26 Ford delivered its 1 millionth Sync-equipped car, a 2010 Ford Fusion Hybrid, in the Seattle area. To celebrate topping the 1 million mark, Ford President and CEO Alan Mulally personally handed the keys over to its new owner, who happens to be Steve Ballmer, Microsoft's CEO. Ballmer purchased the hybrid sedan as well as a new Ford Flex a few weeks earlier from a local dealership. A joint effort between the automaker and Microsoft, Sync is essentially a small PC that runs on a version of Windows built for the harsh automotive environment. It allows a car's stock radio to seamlessly interface with mobile phones and digital music players, such as an iPhone or Microsoft Zune. It also lets the driver or passenger verbally communicate with and control these devices using voice-activation technology. And since the Sync system is software-based, expanding capability is as easy as installing a new computer program. And it does all of this for less than $400. The Sync system has been a huge success with both the tech-savvy and tech-challenged crowds, which is why it is now installed in more than 80 percent of Ford vehicles sold in North America. Last year Sync added two new applications: Vehicle Health Report and 911 Assist. Ford's latest Sync application, Traffic, Directions and Information, will be available for download this summer. It will provide personalized traffic reports, driving directions and up-to-date information, including business listings, news, sports scores and weather. Ford and Microsoft had a one-year exclusivity agreement, and while the Sync system remains exclusive to Ford, Microsoft can now partner with other car companies to expand the technology offering. Perry Stern's automotive career began 19 years ago as an adviser at a vehicle consulting firm. One of the original staff members of CarPoint, Microsoft's automotive Web site that launched in 1995, he became editor of the site in 2002, which is now known as MSN Autos. Stern has also contributed to MSNBC and various MSN properties in Canada, Japan and Europe. In the market for a new car? MSN Autos is pleased to provide you with information and services designed to save you time, money and hassle. Click to research prices and specifications on any new car on the market or get a free price quote through MSN Autos' New-Car Buying Service. -------- fusion -------- link building--link building -- Posted via http://www.ruby-forum.com/.