WordPress.org

Forums

Loco Translate
[resolved] wrong plural expression in saved PO file (5 posts)

  1. mitk0
    Member
    Posted 1 year ago #

    I believe I found a bug in Loco Translate 1.2.1:

    while combining the locales the $raw array first contains:

    0:<locale name>,1:<no. of plurals>,2:<idx of plural expression>

    plural expression is retrieved with wrong index ($raw[1] instead of $raw[2])

    corrected code ($raw[1] replaced with $raw[2]) in file lib/loco-locales.php:

    $locale = new LocoLocale( $lc, $cc );
            if( isset($locales[$lc]) ){
                if( ! $cc ){
                    $cc = key( $locales[$lc] );
                }
                if( isset($locales[$lc][$cc]) ){
                    $raw = $locales[$lc][$cc];
                    $raw[2] = $plurals[ $raw[2] ];
                    $locale->__import( $lc, $cc, $raw );
                }
            }
            return $locale;

    best regards,
    Mitja

    http://wordpress.org/plugins/loco-translate/

  2. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Hi.
    You're absolutely right. thanks for spotting this.

    I've made a fix in the current development version, which will become 1.2.2.
    http://plugins.svn.wordpress.org/loco-translate/trunk/

    I'd appreciate if you could check this works for you, then I'll publish it to the live release ASAP

    Thanks.

  3. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    I've published this to the current stable version, it seems fine.

  4. mitk0
    Member
    Posted 1 year ago #

    I've tested the trunk - it's OK.

    I had an issue though with the plural expression for Slovenian:

    WP core uses ("old style") expression:
    n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3

    Loco uses the nu style:
    n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0

    Could you perhaps make this configurable?
    Make another settings tab with exposed locales?

    .. just a wish
    It's a great plugin anyway.

  5. timwhitlock
    Member
    Plugin Author

    Posted 1 year ago #

    Interesting to know, thanks.

    I've got a long list of improvements to make and making my rather weak locale selection screen better and more configurable is definitely on the list. I can't promise a timeframe though.

    If you use the full Loco app all locales ARE fully configurable. However, to use the full app with WordPress you'll have to pull down your MO files manually. It's not synced to the WordPress plugin yet, although it will be eventually!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Loco Translate
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic