Comments (8)
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.
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.
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.
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.
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.
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.
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.
Good to know!
thank you for the feedback.
from gettext.
Related Issues (20)
- Cannot install version 5 on PHP 8 HOT 1
- Fatal: strlen() expects parameter 1 to be string MoGenerator.php HOT 1
- Update Documentation HOT 1
- Feature Request: WordPress gettext functions support for scanner HOT 2
- testMoGenerator fails HOT 2
- Why PHP >= 7.2 for Gettext v5? HOT 1
- How to load multiple *.mo files (general and for specific textdomain) HOT 3
- Plural parsing for MO files appears to ignore Plural-Forms HOT 2
- Gettext doesn`t extract template literals from JS HOT 1
- PHP 8.1 compatibility: warnings about JsonSerializable compatibility
- Make use of msgctxt HOT 1
- translations findById HOT 2
- Handling of defective .po files HOT 4
- PHP functions prefixed with a slash are being ignored HOT 3
- add a ?? to string reader for php8.1 in /src/Utils/StringReader.php HOT 2
- what is the equivilent of v4 Gettext->register() in v5? HOT 5
- [question] How to store arbitrary key-value payload in Translation objects, now that it can no longer be faked using references? HOT 1
- Scanner for WordPress (provided repo link) HOT 1
- [Question] Simplest way to promote items in a Translations object to a subclass? HOT 1
- How do I configure to scan files for my own custom funtions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gettext.