Closed Bug 1044138 Opened 10 years ago Closed 10 years ago

Allow usage of l20n parser in NodeJS

Categories

(L20n :: JS Library, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: jaroslaw, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36

Steps to reproduce:

I wanted to create l20n files linter and a task to run it to check if my l20n file has no duplicated entities and to know which entities are missing for which languages.
I use a803a43


Actual results:

Library expects to be run in the browser but some of its parts - this time the Parser might be environment independent.


Expected results:

l20n parser should run in NodeJS without requiring window, document `location` property and 2 functions: `addEventListener` and `removeEventListener`
Severity: normal → enhancement
(In reply to Jarek Rencz from comment #0)
> Library expects to be run in the browser

That's not actually true, only some functionality requires the browser environment (if you think otherwise, please attach a concrete code part that breaks in Node).

For example, this works fine:

    var l20n = require('l20n');
    var ctx = l20n.getContext();
    ctx.linkResource('./pl.l20n'); // you need to have the pl.l20n file in the current directory
    // The following works assuming pl.l20n has translations for keys 'Collections' and 'Items':
    ctx.localize(['Collections', 'Items'], function (l10n) {
        console.log(l10n.entities);
    });

This will log an object with keys 'Collections' and 'Items' and values containing translating entities.

It's just that there is AFAIK no exposed API to get all registered keys for a given locale, one can only get localization entities for a specific key. I assume that's what you're reporting?
thank, I've been trying to load version built for the browser instead of the one from npm. My bad.
Ticket is invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.