Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: properly extract escaped characters and respect default namespace in magic comments #91

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

stepan662
Copy link
Contributor

No description provided.

@stepan662 stepan662 requested a review from cyyynthia July 2, 2024 13:23
@stepan662 stepan662 mentioned this pull request Jul 2, 2024
@stepan662 stepan662 merged commit 6112e40 into main Jul 3, 2024
4 checks passed
@stepan662 stepan662 deleted the stepangranat/extractor-small-fixes branch July 3, 2024 07:55
Copy link

github-actions bot commented Jul 3, 2024

🎉 This PR is included in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@OrenChapo
Copy link

Seems like --default-namespace is still ignored in @tolgee-key comments in v2.1.1. Example code:

// @tolgee-key { "ns": "ui", "key": "errors.cy1001", "defaultValue": "User not found." }

(the above comment works as expected, ui namespace assumed)

// @tolgee-key { "key": "errors.cy1001", "defaultValue": "User not found." }

(the above comment doesn't work; it assumes default namespace instead of ui)

tolgee sync --default-namespace ui -pt "./src/**/*.ts" "./src/**/*.vue"

(the above is the command I run).

Maybe the issue is specific to JSON comments?
Or maybe it happens when there's no t function at all?
Try to add this test (copy-pasted-and-modified your test):

    it('respects default namespace in magic comments with JSON', async () => {
      const report = await getReport(
        `
        // @tolgee-key { "key": "key-override", "defaultValue": "Default Text." }
        `,
        FILE_NAME,
        'react',
        { defaultNamespace: 'namespace' }
      );

      expect(report.keys).toEqual([
        { keyName: 'key-override', namespace: 'namespace', defaultValue: 'Default Text.', line: 2 },
      ]);
    });

@stepan662
Copy link
Contributor Author

Ah you are right, I've fixed in on only one place, but the case when it doesn't override anything in code was treated separately. So I've unified the cases into one function, where it's fixed.

#94

@OrenChapo
Copy link

I confirm #94 fixes my issue. Thanks again Stephan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants