Skip to content
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

Tweak: create pot file with WP CLI and move translations to JS files #1014

Merged
merged 60 commits into from
Mar 10, 2023

Conversation

ravinderk
Copy link
Contributor

@ravinderk ravinderk commented Feb 9, 2023

Description of the Change

I create a bash script that uses package.json --> files to create a pot file for the addon. I implemented EnqueueScript, which manages script dependencies and versions based on the asset file generated by @wordpress/dependency-extraction-webpack-plugin package.

Closes #947 #267 #660

How to test the Change

  • Run npm run makepot command. It should generate a translation file that contains translations from a javascript file (only in dist/js directory).
  • Each script and style file should load correctly, which their versions and dependencies mentioned in the assets file.
  • Each feature depends upon javascript and should work as expected.
  • You should be able to edit translatable strings in Javascript or PHP files. You can use Loco translate plugin for testing.
    Action Screenshot
    Edit string image image
    View edited string Screenshot 2023-03-06 at 10 14 52 PM
    Translation files in plugin directory image

Changelog Entry

Added - Generate POT file with WP-CLI.
Added - Register scripts with EnqueueScript class.

Notable Changes

  • Rename ./tests/php/bootstrap.php.dist --> ./tests/php/bootstrap.php to get code editor support.

Todo before release

  • Ensure WP CLI exists in the built environment before generating the pot file.

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

I create a bash script which uses package,json -> files to create pot file for addon.
@ravinderk ravinderk self-assigned this Feb 9, 2023
@ravinderk ravinderk added this to the 2.0.0 milestone Feb 9, 2023
@ravinderk ravinderk force-pushed the fix/translate-js-files-947 branch from a8661c7 to fd218d5 Compare February 9, 2023 19:17
@ravinderk ravinderk force-pushed the fix/translate-js-files-947 branch from 17d7548 to d46277e Compare February 24, 2023 17:53
@ravinderk ravinderk force-pushed the fix/translate-js-files-947 branch from d46277e to c7e1ac4 Compare February 24, 2023 17:59
@ravinderk ravinderk changed the title Add: create pot file with WP cli Tweak: create pot file with WP cli and move translations to JS files Mar 6, 2023
@ravinderk ravinderk requested a review from peterwilsoncc March 7, 2023 04:00
@ravinderk ravinderk marked this pull request as ready for review March 7, 2023 06:58
@ravinderk ravinderk requested review from jeffpaul and a team as code owners March 7, 2023 06:58
@ravinderk ravinderk changed the title Tweak: create pot file with WP cli and move translations to JS files Tweak: create pot file with WP CLI and move translations to JS files Mar 7, 2023
ravinderk and others added 2 commits March 7, 2023 17:10
# Conflicts:
#	includes/push-ui.php
#	includes/syndicated-post-ui.php
@peterwilsoncc
Copy link
Collaborator

@ravinderk FYI, I've pushed in develop after merging #1022 -- I figured I'd do it as I knew it would create merge conflicts that would need to be resolved.

includes/bootstrap.php Outdated Show resolved Hide resolved
.github/workflows/generate-zip.yml Show resolved Hide resolved
tests/php/EnqueueScriptTest.php Show resolved Hide resolved
@ravinderk ravinderk requested a review from peterwilsoncc March 9, 2023 04:23
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ravinderk, this looks good to me.

@peterwilsoncc peterwilsoncc merged commit 7cced9d into develop Mar 10, 2023
@peterwilsoncc peterwilsoncc deleted the fix/translate-js-files-947 branch March 10, 2023 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants