I bought Agile Web Development With Rails, and followed most of it's directions on setting up the database to accept and decipher utf-8. Up to this point, it works wonderfully (especially for a website with some Japanese translations) except for one problem: ruby (don't think it's rail's fault) doesn't seem to accept Japanese letters in their code. When I command, "rake db:migrate", it gives me an error that character "\336" in one of my migration is indecipherable. I suspect rake is having a problem with the default value I've given a migration to insert for a Japanese name. Furthermore, I need a hash to automatically translate a few english words into japanese. Assuming the problem resides in ruby itself, there's no way I can make one inside rail's controller. Is there some way to initialize a hash with english words as keys, and japanese words (as in, Chars objects) as buckets outside of migration/controller/model, and import that into a migration/controller/model? Thanks in advance!
on 2007-06-19 17:28
on 2007-06-20 01:06
Hello Taro, The problem with using hiragana, karakana or kanji is that Rails will not be able to work out what the pluralizations are. Further, I am not sure what sort of support you will get from databases having kana table names or column names. Ruby is written by a Japanese guy (Matz) and it is all in English. The reason for this I believe is that almost all programming languages use English as a base language. I would recommend keeping your table names and all code in the default language of English. This will also avoid future possible bugs that come up because the new plugin you installed only handles English table names. If you must, you can put romanji in the table names, this would be close enough. But then you would also need to define custom pluralizations for all of these tables as Rails will not know what the plural of nihonjin would be. In fact... there isn't even a plural in your language for that... so you might have a problem there :) Instead, just use JapanesePerson for your model which pluralises to japanese_people (which would be your table name) and all will be good. As a side note, I am doing a LOT of work with Japanese characters and Rails and Ruby handle them fine! Just make sure to use ActiveSupport Multibyte .chars method whenever you are dealing with those UTF8 characters. Later Mikel
on 2007-06-20 18:00
Sorry, maybe I wasn't clear enough: my model contains english names AND japanese names (of course, in seperate columns). The trouble is, in my migration, I want to set a certain column's default value to a japanese word. I could probably do this in my model program instead. Would that work out? Does rail model's run even with japanese characters in them? And, on a side note, why the heck can't Rad Rails read unicode charaters? Is it due to Eclipse itself?