Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fujiwarat opened this issue Oct 31, 2016 · 0 comments

Comments

@fujiwarat
Copy link

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant