[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Using (x)gettext with Ruby files

Sascha Ebach

3/7/2005 7:53:00 AM

Hi,

I want to localize some Ruby files and was trying to use xgettext. It
doesn't support Ruby as a language. All I want to do though is extract
everything within _("") and _(''). Are there any recommendations on how
to use gettext / xgettext with Ruby files? When I run xgettext through
my files I get messages like these:

xgettext: warning: file `helpers/application_helper.rb' extension `rb'
is unknown; will try C

and

controllers/page_controller.rb:39: warning: unterminated character constant

The second message comes from a comment which includes a '

# ... don't ...

Obviously it nows nothing about Ruby.

I also found rgettext, but it's functionality is very limited.

How do you extract your strings from your Ruby files?

Sascha


8 Answers

Christian Neukirchen

3/7/2005 3:36:00 PM

0

Sascha Ebach <se@digitale-wertschoepfung.de> writes:

> Hi,
>
> I want to localize some Ruby files and was trying to use xgettext. It
> doesn't support Ruby as a language. All I want to do though is extract
> everything within _("") and _(''). Are there any recommendations on
> how to use gettext / xgettext with Ruby files?

> How do you extract your strings from your Ruby files?

How about definining _() to log all occurring strings?

> Sascha
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneuk...


gabriele renzi

3/7/2005 4:57:00 PM

0

Christian Neukirchen ha scritto:

>
>>How do you extract your strings from your Ruby files?
>
>
> How about definining _() to log all occurring strings?
>

this is exxactly how ruby-gettext does, IIRC

Sascha Ebach

3/7/2005 6:15:00 PM

0

Christian Neukirchen schrieb:
> Sascha Ebach <se@digitale-wertschoepfung.de> writes:
>
>
>>Hi,
>>
>>I want to localize some Ruby files and was trying to use xgettext. It
>>doesn't support Ruby as a language. All I want to do though is extract
>>everything within _("") and _(''). Are there any recommendations on
>>how to use gettext / xgettext with Ruby files?
>
>
>>How do you extract your strings from your Ruby files?
>
>
> How about definining _() to log all occurring strings?

I don't understand exactly what you mean by that. I want to be able to
use poedit on indexed files. So I will have to use a a harvester to
create the po files. poedit can then take care of versioning issues.
There is the MLL library[1], but it saves it's strings in YAML format. I
have nothing against YAML, but the problem is that you cannot use the
tools that already exist for working with po files.

I also tried to find a gettext mailing list where I could report this
issue, but there doesn't seem to be one. Or did I just not find it?

Sascha

[1] http://dev.digitpaint.nl/pr...


Laurent Sansonetti

3/7/2005 6:43:00 PM

0

Hi,

On Mon, 7 Mar 2005 16:52:53 +0900, Sascha Ebach
<se@digitale-wertschoepfung.de> wrote:
> Hi,
>
> I want to localize some Ruby files and was trying to use xgettext. It
> doesn't support Ruby as a language. All I want to do though is extract
> everything within _("") and _(''). Are there any recommendations on how
> to use gettext / xgettext with Ruby files? When I run xgettext through
> my files I get messages like these:
>
> xgettext: warning: file `helpers/application_helper.rb' extension `rb'
> is unknown; will try C
>
> and
>
> controllers/page_controller.rb:39: warning: unterminated character constant
>
> The second message comes from a comment which includes a '
>
> # ... don't ...
>
> Obviously it nows nothing about Ruby.
>
> I also found rgettext, but it's functionality is very limited.
>
> How do you extract your strings from your Ruby files?
>

In Alexandria (alexandria.rubyforge.org) I use rgettext from
Ruby-GetText package, as follow:

rgettext <ruby_files> -o <pot_file>

And it works perfectly, since the beginning. It supports splitted
strings with + or \.

HTH,

Laurent


gabriele renzi

3/7/2005 6:52:00 PM

0

gabriele renzi ha scritto:
> Christian Neukirchen ha scritto:
>
>>
>>> How do you extract your strings from your Ruby files?
>>
>>
>>
>> How about definining _() to log all occurring strings?
>>
>
> this is exxactly how ruby-gettext does, IIRC

ignore this message, I somewhat skipped "to log" while reading :/

Sascha Ebach

3/7/2005 9:39:00 PM

0

Laurent Sansonetti wrote:
> In Alexandria (alexandria.rubyforge.org) I use rgettext from
> Ruby-GetText package, as follow:
>
> rgettext <ruby_files> -o <pot_file>
>
> And it works perfectly, since the beginning. It supports splitted
> strings with + or \.

I will have a look at that, but what if you have lots of <ruby_files>?
there is a limit on how many files you can pass as arguments. I suspect
I will probably have to modify rgettext. Maybe it could accept a glob.

Thanks for the tip
Sascha


Laurent Sansonetti

3/7/2005 9:51:00 PM

0

Hi,

On Tue, 8 Mar 2005 06:39:00 +0900, Sascha Ebach
<se@digitale-wertschoepfung.de> wrote:
> Laurent Sansonetti wrote:
> > In Alexandria (alexandria.rubyforge.org) I use rgettext from
> > Ruby-GetText package, as follow:
> >
> > rgettext <ruby_files> -o <pot_file>
> >
> > And it works perfectly, since the beginning. It supports splitted
> > strings with + or \.
>
> I will have a look at that, but what if you have lots of <ruby_files>?
> there is a limit on how many files you can pass as arguments. I suspect
> I will probably have to modify rgettext. Maybe it could accept a glob.
>

I do not think there is a limit (except your shell's, or maybe Ruby
itself). Actually I ran it with 38 files at once, without any problem
:)

Cheers

Laurent


Sascha Ebach

3/7/2005 10:51:00 PM

0

Laurent Sansonetti schrieb:
> Hi,
>
> On Tue, 8 Mar 2005 06:39:00 +0900, Sascha Ebach
> <se@digitale-wertschoepfung.de> wrote:
>
>>Laurent Sansonetti wrote:
>>
>>>In Alexandria (alexandria.rubyforge.org) I use rgettext from
>>>Ruby-GetText package, as follow:
>>>
>>>rgettext <ruby_files> -o <pot_file>
>>>
>>>And it works perfectly, since the beginning. It supports splitted
>>>strings with + or \.
>>
>>I will have a look at that, but what if you have lots of <ruby_files>?
>>there is a limit on how many files you can pass as arguments. I suspect
>>I will probably have to modify rgettext. Maybe it could accept a glob.
>>
>
>
> I do not think there is a limit (except your shell's, or maybe Ruby
> itself). Actually I ran it with 38 files at once, without any problem
> :)

The shell has the limit I think. That is the reaons for programs like
xargs. Try it with 300 or 1000 files to see what I mean.

Now that I have thought about it, it shouldn't be that hard to patch up
rgettext.

Did you try to use rgettext on eruby files? If yes, did it work? You
could have something like this:

<html>
<body>
Use gettext for l18n. It has the ability to extract strings via a
function like this _("This text will be translated").
<%= link_to _("Documentation") %>
...

_("This text will be translated") should not be translated. But
everything in between <% .. %> should.

Sascha