Skip to content
New issue

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

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

Already on GitHub? # to your account

Incompatible with ng-bootstrap i18n entries #9

Open
leye0 opened this issue Nov 30, 2018 · 0 comments
Open

Incompatible with ng-bootstrap i18n entries #9

leye0 opened this issue Nov 30, 2018 · 0 comments

Comments

@leye0
Copy link

leye0 commented Nov 30, 2018

This issue is the continuity of tsvetomir/xlf-extract#5.

To summarize, ng-bootstrap trans-units produced by the Angular CLI - ng x18n - don't contain note tags, where these tools read the meaning property to produce an id for the enties.

To make it work with the way ng-bootstrap entry ids are noted, I had to patch the line where the id it fetched so that it fallbacks to the trans-unit id attribute (and comment out the note filter):

    units
        // .filter(unit => unit.find('note').length > 0) // Fix for ng-bootstrap i18n entries;
        .map(unit => {
            const source = doc(unit).find('source');
            let target = doc(unit).find('target');
            if (target.length === 0 && source.length === 1) {
                target = doc('<target />');
                source.after(indent(source), target);
            }

            return {
                target: target,
                id: doc(unit).find('note[from=meaning]').text() || (unit.attribs ? unit.attribs['id'] : null) // Fix for ng-bootstrap;
            };
        }) 

Here's an ng-bootstrap i18n entry:

      <trans-unit id="ngb.timepicker.increment-hours" datatype="html">
        <source>Increment hours</source>
        <context-group purpose="location">
          <context context-type="sourcefile">../node_modules/@ng-bootstrap/ng-bootstrap/timepicker/timepicker.d.ts</context>
          <context context-type="linenumber">9</context>
        </context-group>
      </trans-unit>

Any better way to make it work?

@leye0 leye0 changed the title Incompatible with ng-bootstrap i18n enties Incompatible with ng-bootstrap i18n entries Nov 30, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant