GithubHelp home page GithubHelp logo

node-wp-i18n's People

Contributors

achyuthajoy avatar alessandrotesoro avatar atanas-dev avatar bradyvercher avatar jjj avatar kraftner avatar lc43 avatar nazarkinroman avatar paulgibbs avatar remcotolsma avatar simison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-wp-i18n's Issues

How to set custom POT headers

@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.

'wpi18n addtextdomain --exclude <folder>' not excluding

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.

Remove legacy bbPress exclude from MakePot

Here

return $this->xgettext( 'bp', $dir, $output, array(), array( 'bp-forums/bbpress/.*' ) );
an exclude is added for the bundled version of bbPress v1 that comes bundled inside the BuddyPress plugin.

In the new year, our BuddyPress release is removing this bundled version of bbPress v1, so this exclude's no longer required. :)

Add support for themes with style.css in a subdirectory

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:

  1. All paths in the .pot file will be relative to subdir/ but since languages/ is outside of it, the paths will be incorrect.
  2. Any files with translation function calls outside of 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.

Bump minimist and mkdirp

In trying to trace down some Dependabot alerts, updating the following two lines would help unblock some downstream packages to similarly update:

"minimist": "^1.2.0",

Potentially bump to latest:

"minimist": "^1.2.5",

"mkdirp": "^0.5.1",

Potentially bump to latest:

"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).

Bundle the i18n command from WP-CLI

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.

Function `create_function()` is deprecated

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

'auto_detect_line_endings' INI setting deprecated in PHP 8.1

See: https://php.watch/versions/8.1/auto_detect_line_endings-ini-deprecated

...an explicit ini_set call enables the auto_detect_line_endings directive

Because:

ini_set( 'auto_detect_line_endings', 1 );

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

Get cannot read property of undefined error on first run

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 Warning: "continue" targeting switch is equivalent to "break".

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

Scan JS files

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.

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.