Reputation: 138
This seems incredibly straight forward but for some reason i can't see what the issue is, im trying to import a node module which i've installed, like below
const Y18n = require('y18n')
const i18n = new Y18n()
However i get the following error:
i18n.__ is not a function
Why does this method of import not seem to work, it works for other node modules? Thanks!
Upvotes: 0
Views: 503
Reputation: 48600
Looks like you did not use y18n
correctly, have you checked the README?
const __ = require('y18n')().__;
console.log(__('my awesome string %s', 'foo')); // my awesome string foo
y18n.__(str, arg, arg, arg)
Print a localized string,
%s
will be replaced witharg
s.This function can also be used as a tag for a template literal. You can use it like this:
__`hello ${'world'}`
. This will be equivalent to__('hello %s', 'world')
.
Upvotes: 2