Any working translation framework available for Ruby

Discussion in 'Ruby' started by Michal Suchanek, May 13, 2011.

  1. 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
     
    Michal Suchanek, May 13, 2011
    #1
    1. Advertising

  2. On Fri, May 13, 2011 at 11:11 PM, Michal Suchanek <> 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.
     
    Phillip Gawlowski, May 13, 2011
    #2
    1. Advertising

  3. On 13 May 2011 23:59, Phillip Gawlowski <> wrote:
    > On Fri, May 13, 2011 at 11:11 PM, Michal Suchanek <> 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
     
    Michal Suchanek, May 14, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kikoz
    Replies:
    6
    Views:
    394
    Indentix, Inc.
    Jul 27, 2004
  2. Olaf \El Blanco\

    Spanish Translation of any python Book?

    Olaf \El Blanco\, Jan 13, 2006, in forum: Python
    Replies:
    6
    Views:
    1,295
    jean-michel bain-cornu
    Jan 15, 2006
  3. canthurt2ask.com

    Translation Tool not working properly

    canthurt2ask.com, Oct 11, 2007, in forum: HTML
    Replies:
    3
    Views:
    325
    Neredbojias
    Oct 11, 2007
  4. Alis
    Replies:
    3
    Views:
    482
    Diez B. Roggisch
    Jul 17, 2008
  5. Varun Goel
    Replies:
    1
    Views:
    107
    Thomas Wieczorek
    Mar 3, 2008
Loading...

Share This Page