Git Product home page Git Product logo

Comments (8)

oscarotero avatar oscarotero commented on May 17, 2024

mmm, interesting...
Plural original string is stored in the key "0", but it's never used, so, it could be removed. The problem is backward compatibility, becasue PhpArray is used not only for Jed, but also for the generators phpArray and jsonDictionary.
I'm not feeling bad about making this change, but this affects to these generators and even the Translator class (that used the same structure https://github.com/oscarotero/Gettext/blob/master/src/Translator.php#L192)

from gettext.

g-johnson avatar g-johnson commented on May 17, 2024

I have it working with the patch, but other people who would like to use the utility with Jed will certainly desire this fixed.

After I posted the initial issue, I noticed that the plural structure was not working as well. I edited the original post to reflect this.

I understand your desire not to modify the phpArray structure. Maybe the array could be refactored in the Jed method just before it is Json’ed.

from gettext.

oscarotero avatar oscarotero commented on May 17, 2024

Maybe a good solution is to provide a way to convert the old array structure to the new one. So, people upgrading this library can easily update their phpArray files. Maybe an oldPhpArray extractor or something like that.

from gettext.

oscarotero avatar oscarotero commented on May 17, 2024

Hello, @g-johnson
After thinking a little more, I decided to change only Jed generator/extractor instead all phpArray dependencies. Not only because backward compatibility but also to maintain compatibility between phpArray and other formats (For example, po format has the original plural string too, so it's better to convert array to po and po to array).

Before release this patch, can you test if Jed format works fine now, please?
Feel free also to make a Pull request if you see something to change.
Thanks

from gettext.

g-johnson avatar g-johnson commented on May 17, 2024

The \gettext\Generators\Jed: toString is inheriting the \gettext\Generators\PhpArray:toArray method which in turn uses the incorrect PhpArray:buildArray method. Cloning the buildArray method from PhpArray to Jed fixes this inheritance problem although there may me a more elegant way.

Thank you for your prompt response to this issue...

from gettext.

oscarotero avatar oscarotero commented on May 17, 2024

Ok, I made a mistake putting self instead static.

The only differente between Jed and PhpArray is the block you've put in this issue, so I've created a method with this code https://github.com/oscarotero/Gettext/blob/master/src/Generators/PhpArray.php#L59 and Jed generator extends phpArray overriding this method https://github.com/oscarotero/Gettext/blob/master/src/Generators/Jed.php#L22
This avoid code duplication.

from gettext.

g-johnson avatar g-johnson commented on May 17, 2024

The Jed Generator is working correctly now and Jed is translating both singular and plural text perfectly.

Your prompt assistance was much appreciated!

The issue can be closed.

from gettext.

oscarotero avatar oscarotero commented on May 17, 2024

Good to know!
thank you for the feedback.

from gettext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.