Skip to content

Adding langs and namespaces exports - #36

Merged
rosskevin merged 11 commits into
alienfast:mainfrom
YPetremann:main
Jul 1, 2026
Merged

rosskevin merged 11 commits into
alienfast:mainfrom
YPetremann:main

Conversation

@YPetremann

Copy link
Copy Markdown
Contributor

This proposal add langs and namespaces exports to the bundle. This would allow to automaticaly set supportedLngs and ns while being tree-shaked

- import resources from "virtual:i18next-loader";
+ import { langs, namespaces } from "virtual:i18next-loader";
  i18next.init({
-   supportedLngs: Object.keys(resources),
-   ns: Object.keys(resources.key),
+   supportedLngs: langs,
+   ns: namespaces,
    fallbackLng: ["en"],
    detection: {
      order: ["htmlTag"],
      caches: [],
    },
    backend: { loadPath: "/api/locales/{{lng}}/{{ns}}" },
  });

This is usefull when the resources should not be in the client bundle and loaded from other ways.

@rosskevin

Copy link
Copy Markdown
Member

Thanks @YPetremann - can you add some tests for the new features?

@rosskevin rosskevin added minor Increment the minor version when merged enhancement New feature or request labels Jun 29, 2026
@YPetremann

YPetremann commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor Author

(just for note, it's maybe not important but it bugs me, I don't know "auto shipit", what are the required steps to not get the release fail ?)

I will do it soon.

@YPetremann

Copy link
Copy Markdown
Contributor Author

I updated the assertCommon of thoses tests files to check for langs and namespaces:
basic.test.ts // infer namespaces from files
namespaceResolverBasename.test.ts // infer namespace from basename
namespaceResolverRelativePath.test.ts // infer namespace from first segment of path

@rosskevin

Copy link
Copy Markdown
Member

(just for note, it's maybe not important but it bugs me, I don't know "auto shipit", what are the required steps to not get the release fail ?)

I will do it soon.

Yeah, this bugs me too. I love the tool, but for outside contributors I haven't figured out the right combination. It is set up with trusted OIDC but only works when I push.

Thank you, and sorry for the delay.

@rosskevin
rosskevin merged commit cda2e9e into alienfast:main Jul 1, 2026
3 of 4 checks passed
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 PR was released in v4.1.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Increment the minor version when merged released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants