[ruby-gnome2-doc-cvs] [Hiki] update - tips_i18n

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2003年 8月 29日 (金) 18:34:18 JST


-------------------------
REMOTE_ADDR = 61.204.181.66
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/?tips_i18n
-------------------------
  = How to write the non-ascii texts
  All strings you pass to GTK+ functions must be in UTF-8. 
  Of course, Ruby-GNOME2 has the same requirement.
  
  Usually, you have written ruby scripts in your locale and charset, which isn't necessarily UTF-8.
  
  So you may be confused about how to write texts in Ruby-GNOME2 at first.
  
  Here is a summary of your options:
  
  == 1 Write scripts in UTF-8
  This is the easiest way if you use an editor that supports UTF-8.
  
- It may help to define $KCODE = 'u' in the head of your script.
+ You need to define $KCODE = 'u' in the head of your script.
  
   $KCODE = 'u'
   require 'gtk2'
   
   ...
  
  Also you can use the -K option to Ruby.
  
  == 2 Write the script in your charset and convert it with iconv
  Write your script with your favorite editor which doesn't support UTF-8.
  You save it with your own (non-UTF-8) charset.
  
  Then you convert it with iconv when you run it.
  
   iconv -f <your charset> -t utf-8 foo.rb |ruby -
   iconv -f euc-jp -t utf-8 foo.rb |ruby -
  
- Effectively, this is the same as the first method. So it may again be better to define $KCODE = 'u' in your script.
+ Effectively, this is the same as the first method. So you need to define $KCODE = 'u' in your script.
  
  == 3 Use GLib.convert for each string.
  GLib.convert converts a string from one character set to another. 
  
   require 'gtk2'
   
   Gtk::Button.new(GLib.convert("RYOUKAI", "utf-8", "euc-jp"))  #str, to, from
  
  I don't recommand this way for static texts. Usually you should use GLib.convert when you read non-ascii, non-utf-8 texts from files or
  networks.
  
  == 4 ((<Ruby-GetText-Package|URL:http://ponx.s5.xrea.com/hiki/ruby-gettext.html>))
  So far, they don't support i18n (L10n). It may be no problem if you distribute your scripts locally. 
  But if you want to distribute it whole the world, you need to support i18n (L10n). 
  
  ((<Ruby-GetText-Package|URL:http://ponx.s5.xrea.com/hiki/ruby-gettext.html>))
  is the one of the solutions which automates replacing English text with localized text.
  It's also compatible with the GNU gettext Package. 
  Try it if you are interested.
  
  == ChangeLog
+ :2003-08-29 Masao Mutoh
+  Change the treatments of $KCODE="u" 
  :2003-07-08 Evan Martin 
   Fixed up the English
  :2003-07-08 Masao Mutoh
   Initial Release





ruby-gnome2-cvs メーリングリストの案内
Zurück zum Archiv-Index