New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp-cli make-json and Loco Translate support for admin dashboard. #36739
Conversation
Hi @kenarsuleyman, thanks for your contribution. Could you please make the following adjustments to your pull request:
|
@Konamiman Thanks for the clear instructions. For some reason, both |
if ( ! isset( $chunk_data['comment']['reference'] ) ) { | ||
// Support for wp-cli --make-json and Loco Translate file format. | ||
|
||
if ( ! ( isset( $chunk_data['comment']['reference'] ) || isset( $chunk_data['source'] ) ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better extracting each parser into separate functions rather than lumping them into one. For me, the resulting nested if
branch conditions add too much complexity to this function.
An alternative might be to have get_translation_chunk_data
, perform heuristics on the file to detect the format, and then call the appropriate parser function for that format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kenarsuleyman, Would you be able to make a change as Adrian's suggestion? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @chihsuan since this is only a workaround fix and will get reverted sometime in near future, I might refactor the entire function based on Adrian's suggestion. Right now I don't know how long this fix needs to stay in the codebase. If current version is not suitable for standarts to merge it, I can do it this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If current version is not suitable for standarts to merge it, I can do it this week.
Hi @kenarsuleyman Yeah, I think that would be perfect, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @adrianduffell, I wrote separate functions to combine translation chunks after your suggestion. I agree that this made the code more readable only problem is I'm not fully happy how those separate functions ended up with. There are "duplicate looking" lines, they are not exact duplicates, just the same logic for different file formats. Unfortunately, I couldn't think of a more optimized approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kenarsuleyman Just saw you push a new commit, we will review it soon. 👍 Thank you!
Sorry for late notice, @adrianduffell is unavailable.
Hi @kenarsuleyman, thanks for this PR and your contribution. I think it's valuable to fix the bug. I'd like to better understand why the formats are different between the official and Loco Translate generated files. Is it an error / deviation in the way one of them is generating the files? I think ideally, we should aim to have the tooling converge to provide the data in the same format, rather than adding complexity at WooCommerce's end in supporting multiple formats. |
About the difference, I also agree to focus on why there is a difference between files in the first place. I checked the changelog for both GlotPress(based on official files, It's generated by GlotPress) and Loco, but couldn't see any reference to this format change. Since wp-cli and Loco has same formats and GlotPress has a different format, the problem is most likely caused by GlotPress. Do you think is it better to write a workaround like this and revert it after the underlying problem gets fixed, or try to find a way to fix the underlying issue( which I don't exactly know )? |
Hi @kenarsuleyman, thanks for the explanation. I think it would be good to merge this as a temporary workaround, while aiming to fix the underlying issue in the meantime. We'll want to merge it by Monday 20 Feb to land it safely in the next release. I'll take a further look this week. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #36739 +/- ##
==========================================
- Coverage 46.7% 46.7% -0.0%
Complexity 17178 17178
==========================================
Files 429 429
Lines 64779 64779
==========================================
- Hits 30242 30240 -2
- Misses 34537 34539 +2
|
Added seperate parsers for chunk files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! @kenarsuleyman LGTM and tested well.
@moon0326 Could you also look at this when you get a chance? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tested well! 🚀
Hey @Konamiman, I've reviewed this instead of @moon0326. I'll go ahead and merge now to meet the code freeze deadline. |
Thanks for the PR @kenarsuleyman ! |
It was pleasure for me 🙌 |
All Submissions:
Changes proposed in this Pull Request:
Closes #35500 .
How to test the changes in this Pull Request:
*languages/plugins/woocommerce-az.po
*languages/loco/plugins/woocommerce-az.po
*plugins/woocommerce/i18n/languages/woocommerce-az.po
Short summary of bug
Due to file format difference between the official and generated chunk files, WooCommerce was unable to generate combined JSON file.
Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: