diff --git a/.changeset/allow-valid-locale-codes.md b/.changeset/allow-valid-locale-codes.md new file mode 100644 index 000000000..b3131f2ee --- /dev/null +++ b/.changeset/allow-valid-locale-codes.md @@ -0,0 +1,5 @@ +--- +"@lingo.dev/_spec": minor +--- + +Allow any valid ISO locale code in validation instead of hardcoded list. Validation now accepts any locale conforming to ISO 639-1, ISO 15924, ISO 3166-1, and UN M.49 standards. diff --git a/CLAUDE.md b/CLAUDE.md index e195030c5..cf51f307f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,4 +10,10 @@ ## Testing -- When you add tests - make sure they pass \ No newline at end of file +- When you add tests - make sure they pass + +## Changesets + +- Every PR must include a changeset +- Create changeset: `pnpm new` from repo root +- For changes that don't need a release (e.g., README updates): `pnpm new:empty` \ No newline at end of file diff --git a/packages/spec/package.json b/packages/spec/package.json index c572975aa..528227aa0 100644 --- a/packages/spec/package.json +++ b/packages/spec/package.json @@ -25,6 +25,7 @@ "author": "", "license": "Apache-2.0", "dependencies": { + "@lingo.dev/_locales": "workspace:*", "zod": "^3.25.76", "zod-to-json-schema": "^3.24.5" }, diff --git a/packages/spec/src/locales.ts b/packages/spec/src/locales.ts index da954e416..dac57f1b5 100644 --- a/packages/spec/src/locales.ts +++ b/packages/spec/src/locales.ts @@ -1,4 +1,5 @@ import Z from "zod"; +import { isValidLocale } from "@lingo.dev/_locales"; const localeMap = { // Urdu (Pakistan) @@ -246,7 +247,11 @@ export const localeCodes = [ ] as LocaleCode[]; export const localeCodeSchema = Z.string().refine( - (value) => localeCodes.includes(value as any), + (value) => { + // Normalize locale before validation + const normalized = normalizeLocale(value); + return isValidLocale(normalized); + }, { message: "Invalid locale code", }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c506460e..0feceaef3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -928,6 +928,9 @@ importers: packages/spec: dependencies: + '@lingo.dev/_locales': + specifier: workspace:* + version: link:../locales zod: specifier: ^3.25.76 version: 3.25.76