cedaro / node-wp-i18n Goto Github PK
View Code? Open in Web Editor NEWInternationalize WordPress themes and plugins.
License: MIT License
Internationalize WordPress themes and plugins.
License: MIT License
@bradyvercher For Genesis, we want to customize the POT Headers, such as "Report-Msgid-Bugs-To: https://wordpress.org/support/theme/genesis\n"
, since that isn't correct.
We'd also like to include all of the POEdit headers, for those who want to use the .pot
to create new catalogs via POEdit.
We also would like to use npm scripts, rather than the Grunt package that is currently being used.
Could you please explain how we'd go about setting these headers?
(Possibly having the npm script call a custom .js
file that imported wpi18n and then set the desired options.potHeaders
and passed options
to wpi18n.makepot
?)
Having this documented as a section in the Readme would be most helpful for those who want to do this sort of customisation.
I attempted both of the following commands:
wpi18n addtextdomain --exclude vendor
wpi18n addtextdomain --exclude /vendor
In both cases, textdomains in the vendor
folder were overwritten. I'm on Windows 10 with latest Node and NPM and attempting to get this to add the textdomain for a theme but not overwrite anything in the vendor
folder.
Here
node-wp-i18n/bin/php/makepot.php
Line 637 in ac48107
In the new year, our BuddyPress release is removing this bundled version of bbPress v1, so this exclude's no longer required. :)
Crude example of what my setup looks like:
wp-content/themes/my-theme
├── includes/
│ └── helpers.php
├── languages/
│ └── my-theme.pot
├── subdir/
│ └── style.css
└── package.json
As you can see, my style.css
is in a subdirectory (supported by WordPress) which means that I can't run wpi18n
in the root theme directory as it fails to find it.
I tried changing the working directory when running wpi18n (e.g. (cd subdir && wpi18n ...)
) however this has a couple of issues:
.pot
file will be relative to subdir/
but since languages/
is outside of it, the paths will be incorrect.subdir/
like includes/helpers.php
will not get indexed.Let me know if I'm missing anything or support for this use case is indeed not implemented.
In trying to trace down some Dependabot alerts, updating the following two lines would help unblock some downstream packages to similarly update:
Line 27 in 4633a53
"minimist": "^1.2.5",
Line 28 in 4633a53
"mkdirp": "^v1.0.4",
...or...
"mkdirp": "^v0.5.5",
Will need to ensure those don't break any functionality, but will allow downstream packages to similarly account for the updates to minimist
(which is also included in mkdirp
).
I'm not sure if this is an issue with my config or the library itself... 🤔
You're checking the hash without the creation date which is good, but when you reset you actually use the new date because you've read "the old" value after already having regenerated.
With the release of WordPress 5.0 and WP.org switching over to WP-CLI's i18n command, support needs to be added for new features and workflows. Bundling the i18n command from WP-CLI without adding any new dependencies should be possible, however there may be breaking changes due to differences in how the WP-CLI command and old PHP tools worked.
This issue will be used to track the changes and hopefully cover features that may break.
Via https://travis-ci.org/ntwb/bbPress/jobs/237386415#L1077
Deprecated: Function create_function() is deprecated in /tmp/wordpress/src/wp-content/plugins/bbPress/node_modules/grunt-wp-i18n/vendor/wp-i18n-tools/makepot.php on line 181
...
PHP Deprecated: Function create_function() is deprecated in /tmp/wordpress/src/wp-content/plugins/bbPress/node_modules/grunt-wp-i18n/vendor/wp-i18n-tools/pomo/po.php on line 170
The above are the only two notices I see, there's hundreds of the same notice but the rest of the logs are truncated by Travis CI at ~10,000 lines
See: https://php.watch/versions/8.1/auto_detect_line_endings-ini-deprecated
...an explicit
ini_set
call enables theauto_detect_line_endings
directive
Because:
node-wp-i18n/bin/php/pomo/po.php
Line 16 in fc00eef
Causes:
Running "addtextdomain:update_all_domains" (addtextdomain) task
Deprecated: auto_detect_line_endings is deprecated in node_modules/node-wp-i18n/bin/php/pomo/po.php on line 16
Call Stack:
0.0003 423160 1. {main}() node_modules/node-wp-i18n/bin/php/node-add-textdomain.php:0
0.0009 441648 2. require_once('node_modules/node-wp-i18n/bin/php/add-textdomain.php') node_modules/node-wp-i18n/bin/php/node-add-textdomain.php:2
0.0014 574528 3. require_once('node_modules/node-wp-i18n/bin/php/makepot.php') node_modules/node-wp-i18n/bin/php/add-textdomain.php:9
0.0018 614440 4. require_once('node_modules/node-wp-i18n/bin/php/not-gettexted.php') node_modules/node-wp-i18n/bin/php/makepot.php:2
0.0024 683760 5. require_once('node_modules/node-wp-i18n/bin/php/pomo/po.php') node_modules/node-wp-i18n/bin/php/not-gettexted.php:18
0.0032 764096 6. ini_set($option = 'auto_detect_line_endings', $value = 1) node_modules/node-wp-i18n/bin/php/pomo/po.php:16
When:
❯ php -v
PHP 8.1.12 (cli) (built: Oct 30 2022 12:39:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies
with Xdebug v3.1.4, Copyright (c) 2002-2022, by Derick Rethans
with Zend OPcache v8.1.12, Copyright (c), by Zend Technologies
When I run the makepot command for the first time, or when the target pot file doesn't exist, I get the following error. The pot file still generates, and appears to be correct, but the error does occur.
run wpi18n makepot --type=wp-plugin --pot-file="./php.pot"
Unhandled rejection TypeError: Cannot read property 'content-type' of undefined
at normalizeForComparison (MY_PATH/node_modules/node-wp-i18n/lib/pot.js:54:48)
at Pot.sameAs (MY_PATH/node_modules/node-wp-i18n/lib/pot.js:166:32)
at MY_PATH/node_modules/node-wp-i18n/lib/makepot.js:92:43
at tryCatcher (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (MY_PATH/node_modules/node-wp-i18n/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:651:20)
at tryOnImmediate (timers.js:624:5)
at processImmediate [as _immediateCallback] (timers.js:596:5)
When I started looking around, it seemed like the third time normalizeForComparison()
was called, it was called with an empty string. The pot object in sameAs
looks like.
Pot {
isOpen: false,
filename: 'MY_PATH/lang/php.pot',
contents: '',
initialDate: '',
fingerprint: '' }
It seems like if the pot file has an empty contents, that function could return false before normalizing the file. Thoughts?
PHP 7.3 added a warning when continue
word is used under switch
. This leads to warnings in console when running any functions from node-wp-i18n
.
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in node_modules/node-wp-i18n/bin/php/pomo/plural-forms.php on line 210
PHP8 appears to trigger the following warning:
Warning: PO::export_entry(): Argument #1 ($entry) must be passed by reference, value given in /node_modules/.pnpm/[email protected]/node_modules/node-wp-i18n/bin/php/pomo/po.php on line 52
WordPress now allows for translatable strings in JS files with Gutenberg blocks.
They've made it so that the usage is almost identical, assuming you follow the same patterns they do in their source.
Is it possible to allow node-wp-i18n to scan the JS files in a theme/plugin folder for translatable strings? Obviously, we'd need to do so for both addtextdomain
and makepot
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.