Skip to content

nggettext_extract failed to extract translatable string with printf format on html files #59

Open
@fujiwarat

Description

Currently translate attribute works with grunt-angular-gettext but it's not useful for printf format.

E.g. I'd like to use gettext for the following text on html files:

<li>
{{user.status?'Disable':'Enable'}} user
</li>

to

<li>
{{sprintf(i18n._("%s user"), user.status?i18n._('Disable'):i18n._('Enable'))}}
</li>

I set ['_', 'N_'] to markerNames and attributes in Gruntfile.js file
angular-gettext works but grunt nggettext_extract cannot extract "%s user", "Disable" and "Enable".

The following JavaScript file is used:

var gettext = require("angular-gettext");
var sprintf = require("sprintf-js").sprintf;

angular.module('test', ['gettext'])
    .run(function ($rootScope, $window, gettextCatalog) {
        gettextCatalog.setCurrentLanguage('ja');
        gettextCatalog.loadRemote('js/ja.json');
        gettextCatalog._ = gettextCatalog.getString;
        gettextCatalog.N_ = function(s) {
            return s;
        }
        $rootScope.i18n = gettextCatalog;
        $rootScope.sprintf = sprintf;
    });

If I could move those strings on html to JavaScript files, they would work with grunt nggettext_extract but there are a lot of translatable strings.
sprintf() is used to get rid of non-translatable strings likes codes, html tags,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions