Forums

Codestyling Localization
plural form in header of .po language file - bug? (12 posts)

  1. j-prause
    Member
    Posted 4 months ago #

    I have been using Codestyling Localization (CL) plugin successfully for long, translating texts into cs_CZ.
    When translating, CL uses correct plural form for my language, yet after saving translations with 'Create MO' the plural form in .po file is not correct. It changes into the English plural form i.e.
    "Plural-Forms: nplurals=2; plural=n != 1;\n"
    As a result of this the plurals displayed at frontend are not correct!

    http://wordpress.org/extend/plugins/codestyling-localization/

  2. Brozman
    Member
    Posted 4 months ago #

    Hello there,

    I have a problem with plural translations, too.

    All of the translations are automatically saved, right? But when I translate plural stuff, they aren't being saved.

    How is it possible please? Is it some kind of bug?

    Thanks for support :)

  3. mkubenka
    Member
    Posted 4 months ago #

    j-prause:

    change this line in class-translationfile.php (in latest version it's line #339):

    $this->_set_header_from_string("Plural-Forms: \nX-Textdomain-Support: yes");

    to:

    $po_lang = 'en';
    if (preg_match("/([a-z][a-z]_[A-Z][A-Z]).(mo|po)$/", $pofile, $hits)) {
    	$po_lang = $this->strings->_substr($hits[1],0,2);
    }else{
    	$po_lang = $this->strings->_substr($_POST['language'],0,2);
    }		
    
    $this->_set_header_from_string("Plural-Forms: \nX-Textdomain-Support: yes", $po_lang);

    It should fix bad plural forms.

  4. Brozman
    Member
    Posted 4 months ago #

    @mkubenka: I tried this one, but I see no changes.

    I don't think that problem is PEBKAC :D

    Official site seems to be dead

    So what to do?

  5. j-prause
    Member
    Posted 4 months ago #

    @ mkubenka:

    change this line in class-translationfile.php (in latest version it's line #339)

    I tried it.
    Now CL sets the correct plural form into .po file.
    But still the plurals are not displayed correctly at website frontend.
    As to me the .mo file generated by CL is not correct. After opening the .po file with Poedit and saving it then plurals display correctly.

    @ Brozman:
    what do you mean by

    PEBKAC :D
    ?

  6. mkubenka
    Member
    Posted 4 months ago #

    @j-prause:

    hum, problems with .mo files is that header doesn't have LTD (lang. translation domain), so function _is_valid_entry thinks it's non-valid entry.

    I changed function _is_valid_entry in class-translationfile.php (line #524):

    function _is_valid_entry(&$entry, &$textdomain) {
    	return (
    		($this->strings->_strlen(str_replace("", "", $entry['T'])) > 0)
    		&&
    		(in_array($textdomain, $entry['LTD']) || empty($entry['LTD']))
    	);
    }

    Probably, not the best solution, anyway it works :)

  7. j-prause
    Member
    Posted 4 months ago #

    @ mkubenka:
    I can confirm, this works, so far. Thank you.
    Will these changes become part of new plugin version?
    Cheers.

  8. Brozman
    Member
    Posted 4 months ago #

    @j-prause:

    pebkac - problem exists between keyboard and chair :D so I'm the trouble.

    @j-prause:

    can you help me, too? because I've been trying what you've posted but it haven't worked at all.

    my plural forms are still unsaved and I'm going crazy about it.

  9. j-prause
    Member
    Posted 4 months ago #

    @ Brozman:
    What subject are you translating?
    What stage are you at?

  10. j-prause
    Member
    Posted 4 months ago #

    @ Brozman:
    Have you managed your problem?

  11. Brozman
    Member
    Posted 4 months ago #

    Sorry, I've just had tons of tests at school.

    So my problem is that when I try to translate some plural stuff it is not saved, and I don't know why.. Because I'm not programmer.

    Well, I translate it and get back to overview page. After that I click on that translation and that plural phrase doesn't appear there.

    It's very hard to explain for myself, because I'm just intermediate in english.

    Should I rather make a video of my screen?

    Thanks.

  12. j-prause
    Member
    Posted 4 months ago #

    Make whatever you wish but you cannot place the video in a post here, I'm afraid. Send an e-mail to me: josef dot prause at gmail dot com.

Reply

You must log in to post.

About this Plugin

About this Topic