Giter Site home page Giter Site logo

keyword "msgctxt" unknown about grunt-wp-i18n HOT 8 CLOSED

cedaro avatar cedaro commented on June 11, 2024
keyword "msgctxt" unknown

from grunt-wp-i18n.

Comments (8)

vpratfr avatar vpratfr commented on June 11, 2024

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.

bradyvercher avatar bradyvercher commented on June 11, 2024

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.

vpratfr avatar vpratfr commented on June 11, 2024

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.

tlartaud avatar tlartaud commented on June 11, 2024

@vpratfr @bradyvercher

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.

bradyvercher avatar bradyvercher commented on June 11, 2024

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.

tlartaud avatar tlartaud commented on June 11, 2024

Hi @bradyvercher

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.

tlartaud avatar tlartaud commented on June 11, 2024

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

bradyvercher avatar bradyvercher commented on June 11, 2024

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)

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.