ojii / gettext.js

gettext in javascript for the browser, and a mo file compiler.
Other
7 stars 1 forks source link

Add `export gettext = <func>` #5

Open dimaqq opened 4 years ago

dimaqq commented 4 years ago

Currently the module only has a default export, which means it can be used like so:

import gettext from "gettextjs";

xxx = gettext.gettext("Translate me");

If it also had a named exports, it could be used like this:

import {gettext, ngettext} from "gettextjs";

xxx = gettext("Translate me");

And eventually with an alias:

import {gettext as _, ngettext} from "gettextjs";

xxx = _("Translate me");
dimaqq commented 4 years ago

Thanks for the 2.1.0 release but it seems package needs to be built before release, because while named exports are present in src, they are missing from dist 😅 PR coming up :)

dimaqq commented 4 years ago

I'm also not sure why yarn.lock got removed from 2.1.0 and master branch; Thing is, tests fail with new jest (as resolved by package.json), while (I think) they used to pass (using the version from yarn.lock. Maybe it's a good practice for libraries not to lock? In that case I'll try to find an old version of jest that works...

The error is SecurityError: localStorage is not available for opaque origins; it seems that fake dom needs to be configured with some url for local storage to work...