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

Interpolations not working #11

Closed
brian-c opened this issue Jan 12, 2015 · 2 comments
Closed

Interpolations not working #11

brian-c opened this issue Jan 12, 2015 · 2 comments

Comments

@brian-c
Copy link

brian-c commented Jan 12, 2015

Seems to be unable to interpret %(key) here:

https://github.com/maritz/node-sprintf/blob/master/lib/sprintf.js#L199

I noticed that npm's sprintf module is deprecated in favor of sprintf-js. Haven't tried swapping it in, but it's probably worth a look.

To reproduce in Node,

counterpart = require('counterpart');
counterpart.registerTranslations('en', {foo: 'Foo is %(what).'});
counterpart('foo', {what: 'cool'});

results in

Error: [sprintf] %(what).
    at Function.str_format.parse (/node_modules/counterpart/node_modules/sprintf/lib/sprintf.js:231:11)
    at str_format (/node_modules/counterpart/node_modules/sprintf/lib/sprintf.js:75:48)
    at Counterpart._interpolate (/node_modules/counterpart/index.js:233:10)
    at Counterpart.translate (/node_modules/counterpart/index.js:129:18)
    at translate (/node_modules/counterpart/index.js:286:29)
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
@martinandert
Copy link
Owner

You are using the wrong placeholder format. Instead of %(key) you have to use %(key)s. Notice the s at the end.

@brian-c
Copy link
Author

brian-c commented Jan 12, 2015

Totally missed that. Works fine. Thanks!

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

2 participants