Any working translation framework available for Ruby

M

Michal Suchanek

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=E5=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
 
P

Phillip Gawlowski

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.
 
M

Michal Suchanek

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top