WordPress.org

Ready to get started?Download WordPress

Forums

Codestyling Localization
[resolved] plural form in header of .po language file - bug? (14 posts)

  1. j-prause
    Member
    Posted 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years 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 2 years ago #

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

  10. j-prause
    Member
    Posted 2 years ago #

    @ Brozman:
    Have you managed your problem?

  11. Brozman
    Member
    Posted 2 years 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 2 years 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.

  13. Nikola Nikolov
    Member
    Posted 2 years ago #

    Did you had any luck with those? I tried both fixes from above with version 1.99.24, but it's still not working :(
    If I manually edit the .po file and then generate the .mo file from the admin interface, it works. Otherwise the text that is supposed to be displayed is not displayed in neither the original, not the translated language...

  14. codestyling
    Member
    Plugin Author

    Posted 1 year ago #

    Bug has been found and removed with version 1.99.25 comming soon.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic