Skip to content

Improve Portuguese localization and add Brazilian Portuguese (pt-BR)#6076

Open
thristhart wants to merge 2 commits into
colinhacks:mainfrom
thristhart:portuguese-localization
Open

Improve Portuguese localization and add Brazilian Portuguese (pt-BR)#6076
thristhart wants to merge 2 commits into
colinhacks:mainfrom
thristhart:portuguese-localization

Conversation

@thristhart

Copy link
Copy Markdown

In the process of working on a pt-BR translation, our localizers noticed some issues around the usage of articles with the existing Portuguese localization, so we're fixing those while we're here. Let me know if you'd rather have this as two separate PRs.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions inline — one regression in the pt.ts rewrite and a docs typo.

Reviewed changes — rewrites the European Portuguese locale to use article-aware translations and adds a new Brazilian Portuguese locale.

  • Rewrite pt.ts — switches from bare-type-name TypeDictionary entries to article-aware { name, articles } objects; adds translateOriginWithArticle helper; fixes unrecognized_keys (now says "inválida" instead of "desconhecida"); adds invalid_union discriminator-options message; adds missing mac format entry.
  • Add pt-BR.ts — new Brazilian Portuguese locale with the same article-aware structure as the rewritten pt.ts, using Brazilian lexical variants (registro/arquivo/tupla vs registo/ficheiro/tuplo).
  • Register ptBR in the locale barrel and docs.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

}
return `Tipo inválido: esperado ${expected}, recebido ${received}`;
const received = translateOriginWithArticle(receivedType, "indefinite");
return `Entrada inválida: esperava ${expected}, recebeu ${received}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The instanceof check (if (/^[A-Z]/.test(issue.expected))) was dropped from the invalid_type case. When the expected type is a class name like Date, the old code produced "esperado instanceof Date"; now it falls through to the generic "esperava" message with the fallback "um valor "Date"". Same gap in pt-BR.ts.

Comment thread packages/zod/src/v4/locales/pt-BR.ts Outdated
const expected = translateOriginWithArticle(issue.expected, "indefinite");
const receivedType = util.parsedType(issue.input);
const received = translateOriginWithArticle(receivedType, "indefinite");
return `Entrada inválida: esperava ${expected}, recebeu ${received}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing instanceof handling — same as in the rewritten pt.ts. When issue.expected is a constructor name (starts with uppercase), en.ts routes to an "expected instanceof …" message; neither locale handles this path.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

en.ts had the instanceof handling reverted in bf6d99e, so just following the current approach

- `ps` — Pashto
- `pl` — Polish
- `pt` — Portuguese
- `ptBR` — Brazillian Portuguese

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo: BrazillianBrazilian (single 'l').

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Docs typo fixed in the follow-up commit — the invalid_type instanceof concern remains for both locale files (preexisting feedback).

Reviewed changes — formatting follow-up that fixes the "Brazillian" typo and adds trailing newlines.

  • Typo fixBrazillianBrazilian in the docs locale table.
  • Trailing newlines — added missing EOF newlines in pt-BR.ts and pt.ts.

Pullfrog  | Fix it ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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.

1 participant