Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Any working translation framework available for Ruby

Reply
Thread Tools

Any working translation framework available for Ruby

 
 
Michal Suchanek
Guest
Posts: n/a
 
      05-13-2011
Hello,

I am not a believer in translations but given that I can write
decently in two languages I could write a multilingual application
that is intelligible as well and could be possibly translated to other
languages later.

However, there is no usable translation framework I am aware of.

I know that there are gettext bindings and I used the equivalent of
gettext in the past:

def xl msg
xl_hash[msg] ? xl_hash[msg] : msg
end

puts (xl(some_message) %(arg, arg, ...))

However, this is inherently broken.

Suppose that some_message reads:

"%s %i %s from %s to %s.

and the arguments would be, in order {Moving|Copying} <a number>
{files|directories|files and directories} <source location> <target
location>.

The first problem here is that this is a sentence with parametrized
verb, and verbs have predetermined location in the sentence different
across languages. It is at the start in English and at the end in
Japanese meaning that the parameter order is different when the
sentence is translated.

In this simple case it would be easy to make two messages, one for
moving and another for copying but some messages may be quite long and
use more than two different verbs which would explode the number of
strings that have to be written, stored and updated considerably.

A number is not really a problem. In some cases really large numbers
might take up a lot of space and would require the message to be
(re)wrapped. A workaround is to use some engineering or vague notation
like 3k, 3E3, about 3 thousands, ... and make sure to leave enough
room for the longest possible such notation. The problem with "about 3
thousands" is that the length is again language dependent (and that
the numeral needs to be localized) but it's much more readable than
the raw figure when you get to some numbers like 1M and even shorter
when you get to numbers like 1T.

The {files|directories|files and directories} is a tough one. First
problem is in the case there is only one item - an alternative of
{file|directory} is needed. In some languages there are more forms
than a singular and a plural (a la English 1st 2nd 3rd 4th .. 10th
11th 12th .. 20th 21st 22nd 23rd .. .. note the inconsistency). To add
insult to the injury not all languages put the numeral in front of the
counted item (eg. in Japanese as far as I understand it "%i files"
would be something "=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE%i=E 5=86=
=8A" meaning the numeral is actually embedded
inside the part saying "files"!).

The last two are quite easy, I do not know any language where the
locations would cause trouble except you may need to migrate them to a
different place in the sentence.

Seriously, I don't expect there is a translation framework that
handles all of this.

But if there is one that can generate sentences that don't read
completely ridiculous and can be translated into various languages I
would like to hear about it.

Thanks

Michal

 
Reply With Quote
 
 
 
 
Phillip Gawlowski
Guest
Posts: n/a
 
      05-13-2011
On Fri, May 13, 2011 at 11:11 PM, Michal Suchanek <(E-Mail Removed)> wrote:
>
> The first problem here is that this is a sentence with parametrized
> verb, and verbs have predetermined location in the sentence different
> across languages. It is at the start in English and at the end in
> Japanese meaning that the parameter order is different when the
> sentence is translated.
>
> In this simple case it would be easy to make two messages, one for
> moving and another for copying but some messages may be quite long and
> use more than two different verbs which would explode the number of
> strings that have to be written, stored and updated considerably.


Well, you'll *have* to create different messages for
copying/moving/deleting. The only thing you can insert dynamically are
non-translatable parameters (number of files, estimated time [and even
that has to be localized]).

> Seriously, I don't expect there is a translation framework that
> handles all of this.


That's because we don't have natural language processing worth a damn yet.

You'll have to brute force the problem: Strings are translated with
place-holders for data.

> But if there is one that can generate sentences that don't read
> completely ridiculous and can be translated into various languages I
> would like to hear about it.


Take a look at https://github.com/svenfuchs/i18n/wiki. Rails uses it,
and from the looks of it, you store translated strings with parameters
in YAML files named after the language(s) you support.

I haven't used it yet, though.

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.

 
Reply With Quote
 
 
 
 
Michal Suchanek
Guest
Posts: n/a
 
      05-14-2011
On 13 May 2011 23:59, Phillip Gawlowski <(E-Mail Removed)> wrote:
> On Fri, May 13, 2011 at 11:11 PM, Michal Suchanek <(E-Mail Removed)> wrote:
>>
>> The first problem here is that this is a sentence with parametrized
>> verb, and verbs have predetermined location in the sentence different
>> across languages. It is at the start in English and at the end in
>> Japanese meaning that the parameter order is different when the
>> sentence is translated.
>>
>> In this simple case it would be easy to make two messages, one for
>> moving and another for copying but some messages may be quite long and
>> use more than two different verbs which would explode the number of
>> strings that have to be written, stored and updated considerably.

>
> Well, you'll *have* to create different messages for
> copying/moving/deleting. The only thing you can insert dynamically are
> non-translatable parameters (number of files, estimated time [and even
> that has to be localized]).
>
>> Seriously, I don't expect there is a translation framework that
>> handles all of this.

>
> That's because we don't have natural language processing worth a damn yet.
>
> You'll have to brute force the problem: Strings are translated with
> place-holders for data.
>
>> But if there is one that can generate sentences that don't read
>> completely ridiculous and can be translated into various languages I
>> would like to hear about it.

>
> Take a look at https://github.com/svenfuchs/i18n/wiki. Rails uses it,
> and from the looks of it, you store translated strings with parameters
> in YAML files named after the language(s) you support.


Yes, it looks good.

At least it should take care of generating messages for
Moving 1 file | Moving 1st file
Moving 2 files | Moving 2nd file
etc

Thanks

Michal

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco 2600 - Inbound NAT translation/Port-forwarding not working Greg Hardware 0 11-20-2008 07:33 PM
Is there any component-oriented (non-MVC) web framework available forPython? Alis Python 3 07-17-2008 06:00 AM
How many ruby framework available in market? Varun Goel Ruby 1 03-03-2008 10:07 AM
Translation Tool not working properly canthurt2ask.com HTML 3 10-11-2007 02:08 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM



Advertisments