Skip to content

feat(i18n): add native Lunaria key merging#1777

Open
yanthomasdev wants to merge 1 commit intonpmx-dev:mainfrom
yanthomasdev:add-lunaria-merging
Open

feat(i18n): add native Lunaria key merging#1777
yanthomasdev wants to merge 1 commit intonpmx-dev:mainfrom
yanthomasdev:add-lunaria-merging

Conversation

@yanthomasdev
Copy link
Contributor

@yanthomasdev yanthomasdev commented Mar 1, 2026

🔗 Linked issue

🧭 Context

Before, we were using a custom system to add key merging from base locale to variants (e.g. en -> en-US -> en-GB, etc). This PR uses the equivalent feature recently added to Lunaria to do it instead.

📚 Description

It solves the issue we were having with the confusing setup of both i18n and lunaria/files that was creating confusion among contributors.

This PR completely removes lunaria/files and changes the other i18n scripts to adapt to the new structure.

Note: there's a small issue in the dashboard that is making en-US and en-GB be considered complete in the dashboard's progress by locale but not in the table (i.e. the outdated icon -> 🔄), I'll have to look into this yet, but if someone is able to look before me, I appreciate it.

We'll also need to look into every i18n file and see if there's nothing we are missing from other PRs.

@vercel
Copy link

vercel bot commented Mar 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 1, 2026 11:42am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 1, 2026 11:42am
npmx-lunaria Ignored Ignored Mar 1, 2026 11:42am

Request Review

@github-actions
Copy link

github-actions bot commented Mar 1, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/ar-EG.json Localization removed, will be marked as missing.
lunaria/files/az-AZ.json Localization removed, will be marked as missing.
lunaria/files/bg-BG.json Localization removed, will be marked as missing.
lunaria/files/bn-IN.json Localization removed, will be marked as missing.
lunaria/files/cs-CZ.json Localization removed, will be marked as missing.
lunaria/files/de-DE.json Localization removed, will be marked as missing.
lunaria/files/en-GB.json Localization removed, will be marked as missing.
lunaria/files/en-US.json Source removed, will stop being tracked.
lunaria/files/es-419.json Localization removed, will be marked as missing.
lunaria/files/es-ES.json Localization removed, will be marked as missing.
lunaria/files/fr-FR.json Localization removed, will be marked as missing.
lunaria/files/hi-IN.json Localization removed, will be marked as missing.
lunaria/files/hu-HU.json Localization removed, will be marked as missing.
lunaria/files/id-ID.json Localization removed, will be marked as missing.
lunaria/files/it-IT.json Localization removed, will be marked as missing.
lunaria/files/ja-JP.json Localization removed, will be marked as missing.
lunaria/files/mr-IN.json Localization removed, will be marked as missing.
lunaria/files/nb-NO.json Localization removed, will be marked as missing.
lunaria/files/ne-NP.json Localization removed, will be marked as missing.
lunaria/files/pl-PL.json Localization removed, will be marked as missing.
lunaria/files/pt-BR.json Localization removed, will be marked as missing.
lunaria/files/ru-RU.json Localization removed, will be marked as missing.
lunaria/files/ta-IN.json Localization removed, will be marked as missing.
lunaria/files/te-IN.json Localization removed, will be marked as missing.
lunaria/files/uk-UA.json Localization removed, will be marked as missing.
lunaria/files/zh-CN.json Localization removed, will be marked as missing.
lunaria/files/zh-TW.json Localization removed, will be marked as missing.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@yanthomasdev yanthomasdev changed the title Add native Lunaria key merging feat(i18n): add native Lunaria key merging Mar 1, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

📝 Walkthrough

Walkthrough

This PR removes Lunaria tracking files (lunaria/files/\*.json) and refactors the i18n configuration system. The CONTRIBUTING.md workflow is simplified by removing manual file copying steps. The config/i18n.ts module is updated to remove the lunariaJSONFiles export. The lunaria.config.ts file is reworked to construct locales from currentLocales and countryLocaleVariants, introducing runtime validation and creating variant-to-base language mappings. Approximately 20 locale resource files are deleted from the lunaria/files/ directory.

Possibly related PRs

Suggested labels

i18n

Suggested reviewers

  • shuuji3
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly explains the context, motivation, and changes: replacing a custom key-merging system with Lunaria's native feature, removing the lunaria/files module, and addressing contributor confusion.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lunaria.config.ts (1)

27-36: Consider removing the non-null assertion for stricter type safety.

Although baseLang originates from Object.keys() of the same object (making it safe in practice), the ! assertion at line 31 can be replaced with a guard for consistency with the project's strict typing guidelines.

♻️ Proposed refactor
 for (const baseLang of Object.keys(countryLocaleVariants)) {
   if (baseLang === sourceLocale.lang) continue
   if (!localeSet.has(baseLang)) {
-    // Use the first variant's name or the base code as label
-    const variants = countryLocaleVariants[baseLang]!
-    const label = variants[0]?.name ?? baseLang
+    const variants = countryLocaleVariants[baseLang]
+    const label = variants?.[0]?.name ?? baseLang
     localeSet.add(baseLang)
     locales.push({ label, lang: baseLang })
   }
 }

As per coding guidelines: "Ensure you write strictly type-safe code".


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f18d64e and 3f2dd7a.

📒 Files selected for processing (34)
  • CONTRIBUTING.md
  • config/i18n.ts
  • lunaria.config.ts
  • lunaria/files/ar-EG.json
  • lunaria/files/az-AZ.json
  • lunaria/files/bg-BG.json
  • lunaria/files/bn-IN.json
  • lunaria/files/cs-CZ.json
  • lunaria/files/de-DE.json
  • lunaria/files/en-GB.json
  • lunaria/files/en-US.json
  • lunaria/files/es-419.json
  • lunaria/files/es-ES.json
  • lunaria/files/fr-FR.json
  • lunaria/files/hi-IN.json
  • lunaria/files/hu-HU.json
  • lunaria/files/id-ID.json
  • lunaria/files/it-IT.json
  • lunaria/files/ja-JP.json
  • lunaria/files/mr-IN.json
  • lunaria/files/nb-NO.json
  • lunaria/files/ne-NP.json
  • lunaria/files/pl-PL.json
  • lunaria/files/pt-BR.json
  • lunaria/files/ru-RU.json
  • lunaria/files/ta-IN.json
  • lunaria/files/te-IN.json
  • lunaria/files/uk-UA.json
  • lunaria/files/zh-CN.json
  • lunaria/files/zh-TW.json
  • lunaria/lunaria.ts
  • lunaria/prepare-json-files.ts
  • package.json
  • scripts/compare-translations.ts
💤 Files with no reviewable changes (21)
  • lunaria/files/id-ID.json
  • lunaria/files/ja-JP.json
  • lunaria/files/bn-IN.json
  • lunaria/files/hi-IN.json
  • lunaria/files/az-AZ.json
  • lunaria/files/cs-CZ.json
  • lunaria/files/en-GB.json
  • lunaria/files/es-419.json
  • lunaria/files/de-DE.json
  • lunaria/files/ar-EG.json
  • lunaria/files/nb-NO.json
  • lunaria/files/es-ES.json
  • config/i18n.ts
  • lunaria/files/fr-FR.json
  • lunaria/files/it-IT.json
  • lunaria/files/en-US.json
  • lunaria/files/hu-HU.json
  • lunaria/files/ne-NP.json
  • lunaria/files/mr-IN.json
  • lunaria/files/pl-PL.json
  • lunaria/files/bg-BG.json

@trueberryless
Copy link
Contributor

trueberryless commented Mar 1, 2026

The inconsistency between list and table seems to be this expression: https://github.com/yanthomasdev/npmx.dev/blob/3f2dd7a329c97f4c984f02bb0938489c56ab1d95/lunaria/components.ts#L267

Because the list view just uses raw JSON files to determine whether keys are missing, but the table views uses the raw Lunaria status, which includes git timestamps. So alto missingKeys is false because en-US inherits everything, the git timestamps tell the table that the en.json is newer, and therefore localization.status is "outdated".

I'm not totally sure how Lunaria is supposed to use all the available info in the different views, but I would suggest extracting the logic for the correct status into a separate function, so it can consistently be reused.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants