Skip to content

Conversation

@userquin
Copy link
Contributor

@userquin userquin commented Jan 29, 2026

This PR includes:

  • moves i18n configuration to config folder
  • adds support for multiple json files (country variants)
  • allows configure rtl, numberFormats, dateTimeFormats and pluralRule
  • added script to prepare translation json files for lunaria
  • adds Spanish traslations for es-ES and es-419

@vercel
Copy link

vercel bot commented Jan 29, 2026

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

Project Deployment Review Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Jan 29, 2026 0:56am
npmx.dev Ready Ready Preview, Comment Jan 29, 2026 0:56am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
npmx-lunaria Ignored Ignored Preview Jan 29, 2026 0:56am

Request Review

Copy link
Collaborator

@serhalp serhalp left a comment

Choose a reason for hiding this comment

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

🙌🏼 Thank you! Ship it. Some suggestions inline.

Are there changes we should make here to https://github.com/npmx-dev/npmx.dev/blob/main/CONTRIBUTING.md#localization-i18n? It doesn't mention Lunaria atm, so we should probably add discoverable, actionable instructions there.

Would you like me to merge this and follow up in another PR?

Comment on lines +42 to +43
for (let i = 1; i < locale.files.length; i++) {
currentSource = await loadJsonFile(locale.files[i] as string)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
for (let i = 1; i < locale.files.length; i++) {
currentSource = await loadJsonFile(locale.files[i] as string)
for (const file of locale.files.slice(1)) {
currentSource = await loadJsonFile(file)

Copy link
Contributor Author

@userquin userquin Jan 29, 2026

Choose a reason for hiding this comment

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

Slice will create a new array, the code is the same, feel free to apply suggestion if you prefer that notation, I prefer imperative over functional

Comment on lines +34 to +35
"@intlify/core-base": "^11.1.12",
"@intlify/shared": "^11.2.8",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: these can be dev deps, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont use it at runtime so can be a dev dependency (only in future pr for types)

import { currentLocales } from '../config/i18n.ts'
import { deepCopy } from '@intlify/shared'

const destFolder = path.resolve('lunaria/files')
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: how about we add this path to .gitattributes to mark it as containing generated files? https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github

diffs will get collapsed automatically on GitHub

@@ -0,0 +1,545 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

@userquin is it possible to use .json5 or .jsonc with lunaria? it would be great to include a comment at the top of generated files, indicating that it's a generated file and giving a clue as to where to look to make i18n contributions

Copy link
Contributor Author

@userquin userquin Jan 29, 2026

Choose a reason for hiding this comment

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

Iirc we can use [jt]s, json, json5 or yaml, I need to review the docs

Copy link
Contributor Author

@userquin userquin Jan 29, 2026

Choose a reason for hiding this comment

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

Beware about lunaria, I have bo idea if can handle other fornats

Copy link
Contributor Author

@userquin userquin Jan 29, 2026

Choose a reason for hiding this comment

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

And we should update the lunaria logic to merge json5 files, maybe adding some external deps (until lunaria supports files entry)

...data,
code: l.code,
name: l.name,
files: [data.file as string, `${l.code}.json`],
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 why is this type assertion necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

File can be an string or an object, we're using string

@userquin
Copy link
Contributor Author

userquin commented Jan 29, 2026

🙌🏼 Thank you! Ship it. Some suggestions inline.

Are there changes we should make here to https://github.com/npmx-dev/npmx.dev/blob/main/CONTRIBUTING.md#localization-i18n? It doesn't mention Lunaria atm, so we should probably add discoverable, actionable instructions there.

I need to update the contributing file adding some hints from elk.zone: we have some entries for i18n, rtl and unocss rules. I will send the changes once we have this pr merged, maybe tomorrow.

https://github.com/elk-zone/elk/blob/main/CONTRIBUTING.md

Would you like me to merge this and follow up in another PR?

Yes, I was talking with @danielroe on discord, we need to check how to solve html valitator and hydration missmath errors once we store the language on localstorage at client side to restorr it on page refresh: since now we dont persist locale from settings page, we lost the locale on page refresh (and so no missmatch errors). Once we restore locale, we will have client missmatch errors until we fix hydration strategy, Daniel has some idea to fix it.

@skaldebane skaldebane mentioned this pull request Jan 29, 2026
@danielroe danielroe added this pull request to the merge queue Jan 29, 2026
Merged via the queue into npmx-dev:main with commit 484a888 Jan 29, 2026
13 checks passed
shuuji3 pushed a commit to shuuji3/npmx.dev that referenced this pull request Jan 29, 2026
@userquin userquin deleted the feat-move-i18n-configuration branch January 29, 2026 12:01
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.

3 participants