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

Zurück zum Archiv-Index

ruby-****@lists***** ruby-****@lists*****
2003年 7月 10日 (木) 10:30:31 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 is the same.

Usually, you have written ruby scripts in your locale and charset not UTF-8.

So you may confuse how to write the texts in Ruby-GNOME2 at first.

I introduce some way to write non-ascii characters in Ruby-GNOME2.


== 1 Write scripts in UTF-8
This is the easiest way if you use the editors which support UTF-8.

It may be better to define $KCODE = 'u' in the head of your script.

 $KCODE = 'u'
 require 'gtk2'
 
 ...

Also you can use -K option.

== 2 Write 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 charset(not UTF-8).

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 -

As the result, this is the same as 1st way. So it may be better to define $KCODE = 'u' at first.

== 3 Use GLib.convert for each texts.
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 GLib.convert uses when you read non-ascii, non-utf-8 texts from files, networks.

== 4 ((<Ruby-GetText-Package|URL:http://ponx.s5.xrea.com/hiki/ruby-gettext.html>))
So far, they are not 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 solution which replace English texts to localized texts. 
And it's also compatible with GNU GetText Package. 
Try if you are intersted in.


- ((<Masao>))
-------------------------
= How to write the non-ascii texts
All strings you pass to GTK+ functions must be in UTF-8. 
Of course, Ruby-GNOME2 is the same.

Usually, you have written ruby scripts in your locale and charset not UTF-8.

So you may confuse how to write the texts in Ruby-GNOME2 at first.

I introduce some way to write non-ascii characters in Ruby-GNOME2.


== 1 Write scripts in UTF-8
This is the easiest way if you use the editors which support UTF-8.

It may be better to define $KCODE = 'u' in the head of your script.

 $KCODE = 'u'
 require 'gtk2'
 
 ...

Also you can use -K option.

== 2 Write 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 charset(not UTF-8).

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 -

As the result, this is the same as 1st way. So it may be better to define $KCODE = 'u' at first.

== 3 Use GLib.convert for each texts.
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 GLib.convert uses when you read non-ascii, non-utf-8 texts from files, networks.

== 4 ((<Ruby-GetText-Package|URL:http://ponx.s5.xrea.com/hiki/ruby-gettext.html>))
So far, they are not 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 solution which replace English texts to localized texts. 
And it's also compatible with GNU GetText Package. 
Try if you are intersted in.

== ChangeLog
:2003-07-08 ((<Masao>))
 Initial Release




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