Comments (8)
So basically this asks 3 questions (for potential bugs):
- Why aren't those files in node_modules properly ignored?
- Why isn't my function actually removing the guilty POT entries (the log clearly shows that I enter the IFs to delete the entries)?
- Why is the task generating these invalid POT entries?
from grunt-wp-i18n.
Hi @vpratfr, you wouldn't happen to be using the i18nToolsPath
to specify a custom path for the default i18n tools, would you? If so, remove that option and give it another shot.
This module bundles a forked version of the tools, which allows for the exclude
option to be accepted, among a few other things, so all the features aren't available using the default tools.
from grunt-wp-i18n.
That worked. You should make it clear in the docs that it is optionnal and potentially harmful to specify a custom path to i18nTools. Thanks a lot for that tool !
from grunt-wp-i18n.
Hi, This should be re-opened.
I keep getting the keyword "msgctxt" unknown
. Also had a merge ERROR
thrown before that.
The headers are not generated correctly. See below the only configuration that work for me.
module.exports = function (grunt, options) {
var path = require('path');
var poInclude = [
'/*.php',
path.join(options.vars.paths.app, ".*").replace("\\", "/")
];
var poExclude = [
path.join(options.vars.paths.app, "config/example/*.php").replace("\\", "/"),
path.join(options.vars.paths.nodes, ".*").replace("\\", "/"),
path.join(options.vars.paths.vendor, ".*").replace("\\", "/"),
path.join(options.vars.paths.tools, ".*").replace("\\", "/"),
path.join(options.vars.paths.assets, ".*").replace("\\", "/")
];
var processPot = function (pot) {
pot.headers["report-msgid-bugs-to"] = options.pkg.bugs.url + "\n";
pot.headers["last-translator"] = options.pkg.author.name + " <" + options.pkg.author.email + ">\n";
pot.headers["language-team"] = options.pkg.author.url + "\n";
pot.headers["language"] = "en_US";
pot.headers["X-Poedit-WPHeader"] = "style.css";
pot.headers['x-poedit-keywordslist'] = [ '__', '_e', '_n:1,2', '_x:1,2c', '_ex:1,2c', '_nx:4c,1,2', 'esc_attr__', 'esc_attr_e', 'esc_attr_x:1,2c', 'esc_html__', 'esc_html_e', 'esc_html_x:1,2c', '_n_noop:1,2', '_nx_noop:3c,1,2', '__ngettext_noop:1,2'].join(';') + "\n";
for (var i = 0; i < poInclude.length; i++) {
pot.headers['X-Poedit-SearchPath-' + i] = poInclude[i] + "\n";
}
for (var j = 0; j < poExclude.length; j++) {
pot.headers['X-Poedit-SearchPathExcluded-' + j] = poExclude[j] + "\n";
}
var excluded_meta = [
"Plugin Name of the plugin/theme",
"Plugin URI of the plugin/theme",
"Author of the plugin/theme",
"Author URI of the plugin/theme"
];
for (var translation in pot.translations[""]) {
if ("undefined" !== typeof pot.translations[""][translation].comments.extracted) {
if (excluded_meta.indexOf(pot.translations[""][translation].comments.extracted) >= 0) {
console.log("Excluded meta: " + pot.translations[""][translation].comments.extracted);
delete pot.translations[""][translation];
}
}
}
return pot;
};
return {
theme: {
options: {
cwd: process.cwd(),
domainPath: options.vars.paths.languages,
mainFile: "style.css",
potFilename: options.pkg.name + ".pot",
processPot: processPot,
include: poInclude,
exclude: poExclude,
potComments: "(c) " + options.pkg.author.name + " {{year}}",
potHeaders: {
poedit: true,
"x-poedit-keywordslist": true
},
type: "wp-theme",
updateTimestamp: false,
updatePoFiles: true
}
}
};
};
[12:20 ]-[vagrant@vm]-[/var/www/public/app/themes/custom-theme]-[git master]
$ grunt makepot
Running "makepot:theme" (makepot) task
Excluded meta: Author of the plugin/theme
Excluded meta: Author URI of the plugin/theme
>> POT file saved to languages/project-name.pot
>> POT file merged into languages/fr_FR.po
Done, without errors.
Execution Time (2015-10-07 12:28:33 UTC)
loading tasks 512ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 34%
makepot:theme 1s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 66%
Total 1.5s
from grunt-wp-i18n.
Hi @tlartaud, the original issue was related to using an external copy of the core WP i18n tools. Is that what you were having problems with?
Or are there any particular steps I can take to reproduce the issue you were running into?
from grunt-wp-i18n.
I didn't change any setting about WPi18n to make it work.
The important part here are X-Poedit-WPHeader
X-poedit-keywordslist
, and the include / exclude.
Any step to reproduce ?
Yep, you need to try to compile a PHP code using thoses functions : _x
or _nx
etc ...
I updated the keywords list.
from grunt-wp-i18n.
@bradyvercher
The error is to my mind related to .po
file merging from .pot
I always been able to generate the .pot
without any error being thrown.
The message started displaying when i changed the value updatePoFiles
to true
.
To fix that, i've added x-Poedit
headers manually.
from grunt-wp-i18n.
The updatePoFiles
option requires the gettext utilities to be installed and available in your system path for that option to work. There's a note about that in the documentation here.
If you don't have those tools available, then it would make sense that you're receiving an error and changing the headers shouldn't really affect anything.
I hadn't run across the X-Poedit-WPHeader
before. I'll open a new issue to add support for that.
from grunt-wp-i18n.
Related Issues (20)
- Ignore certain domain (e.g. via an options.dontUpdateDomains) HOT 12
- Warning: Cannot read property 'split' of undefined HOT 6
- Exclude page templates HOT 3
- "updateTimestamp: false" is not working properly HOT 3
- Exclude doesn't included in .pot file HOT 2
- Send modified files to build path only HOT 2
- Not Working on Windows ver > 8
- Good way to eliminate duplicates in pot file HOT 8
- Running "makepot" task keeps running forever HOT 4
- update node-wp-i18n to v1.0.5 HOT 1
- updateTimestamp: false not working HOT 8
- Detecting msgid stored in variable HOT 1
- Warning: Cannot read property 'pot-creation-date' of undefined Use --force to continue. HOT 1
- POT File by text domain HOT 2
- Switch to using `wp i18n make-pot` HOT 6
- Makepot supports for monorepo plugins HOT 1
- Addtextdomain throws error HOT 1
- Better output when makepot fails due to missing PHP cli
- Warnings when running on PHP 8 HOT 2
- Duplicate text domains added where text domain already exists HOT 3
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 grunt-wp-i18n.