Skip to content

Incompatible with ng-bootstrap i18n entries #9

@leye0

Description

@leye0

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions