1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
ruby-intl -- A simple wrapper of GNU gettext for ruby
by HIRATA Naoto <hirata-naoto@sannet.ne.jp>
Install:
Require
* Ruby
* GNU gettext
$ ruby extconf.rb
$ make
$ make install
Usage:
You need to have ready for a message catalog beforehand.
Catalogs are quit identical with catalogs for C.
A default location of catalog files is found when a sample program
`hello.rb' is run.
First, you need to create an instance of an Intl class.
An argument of constructor is gettext's domain name.
intl = Intl.new( "hello" );
Second, you call the `_' method of the instance of an Intl class.
A `_' method is an abbreviation of `gettext' method.
print( intl._( "hello world" ), "\n" );
Reference:
Class methods:
new( domain )
Arguments
domain:
Type: String
domain
Description
This method create a new Instance of Intl class.
When a gettext method is called, an argument `domain'
is used as a gettext's domain.
Instance methods:
bindtextdomain( domain, dirname )
Arguments
domain:
Type: String
domain
dirname:
Type: String
directory name where a message catalog exists
Return value
Type: Sring
new directory
Description
This method bind `dirname' to `domain'.
Afte this method is called, gettext will
search for message catalogs under `dirname'.
dcgettext( domain, msgid, category )
Arguments
domain:
Type: String
domain
msgid:
Type: String
gettext's msgid
category:
Type: Fixnum
category for locale
Return Value
Type: String
msgstr corresponding to msgid
Description
This method return msgstr corresponding
to `msgid' from `domain' in `category'.
category for locale is same with C.
dgettext( domian, msgid)
Arguments
domain:
Type: String
domain
msgid:
Type: String
gettext's msgid
Return Value
Type: String
msgstr corresponding to msgid
Description
This method return msgstr
corresponding to `msgid' from `domain'.
gettext( msgid )
_( msgid )
Arguments
msgid:
Type: String
gettext's msgid
Return Value
Type: String
msgstr corresponding to msgid
Description
These methods return a msgstr corresponding to `msgid'.
_ methods is abbreviation of gettext( msgid ).
textdomian( domain )
Arguments
domain:
Type: String
domain
Return Value
Type: Sting
new domain
Description
This method set gettext's domain.
It returns new domain name.
Constants:
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MESSAGES
LC_MONETARY
LC_NUMERIC
LC_TIME
Type:Fixnum
Description
These constants are equivalent to constants
have same name defined in locale.h.
Author HIRATA Naoto
e-mail: hirata-naoto@sannet.ne.jp
web: www.page.sannet.ne.jp/hirata-naoto/
|