i18n-unused icon indicating copy to clipboard operation
i18n-unused copied to clipboard

Namespaces are not handled

Open JesperSporronRocker opened this issue 2 years ago • 7 comments

I have translations that are namespaced, i.e.

const { t } = useTranslation(["shared", "thisFeature"]);
const errorTitle = t("shared:error.defaultTitle");
const pageTitle = t("thisFeature:title");

However i18n-unused does not account for these namespaces, and is showing me that:*

  • shared:error.defaultTitle is missing a translation (when running display-missed).
  • error.defaultTitle is unused (when running display-unused).

I found an ugly fix where display-unused ignores all files that were posted in display-missed, but I can't use that with remove-unused (unless I update the config json). Adding an option to natively support this would be nice :)

JesperSporronRocker avatar May 27 '22 09:05 JesperSporronRocker

Hi, I see your point. I'll look docs about this option and make update at next week. Thx for interest.

mxmvshnvsk avatar May 29 '22 19:05 mxmvshnvsk

I believe the same situation applies to key prefixes, such as:

const { t } = useTranslation("users", { keyPrefix: "index" })

adriandmitroca avatar Jun 07 '22 10:06 adriandmitroca

Unfortunately, I have the same problem of missing namespace support. And as namespaces can be configured in so many ways (even when generating the i18next instance itself), I guess this problem can't be solved perfectly. My suggestion would be to introduce a setting to be more lax. So if a key is not found in any of the locale files, then it is reported as missed. At least this is a hint then that there is something wrong. How about a PR? ;-)

medihack avatar Aug 20 '22 05:08 medihack

@medihack I'm always for new PR's to the repository =)

mxmvshnvsk avatar Aug 20 '22 06:08 mxmvshnvsk