Skip to content

Stabilize useExtracted #2087

@amannn

Description

@amannn

With next-intl@4.5, there's now experimental support for useExtracted.

The next phase will be to collect feedback, fix bugs, potentially incorporate changes and fill in the gaps for missing features and docs.

TODO

  • Fuzzy comments not supported by .po parser (smth else as well?) (ref: there's 1.0 now)
  • Wiped out target locales (ref), Investigate and fix translation file emptying bug #2112
  • Use en for localeCompare everywhere
  • Translations not added (ref)
  • Custom formatters for use cases:
    • PO with source as ID
    • Auto-population for pseudo locale
    • Custom JSON
  • Rename "formatter" to something like "adapter" or "persist" or "codec" to avoid a naming conflict with useFormatter
  • Docs/demo for monorepos (ref)
    • Not shared messages (transpilePackages: ['@acme/ui'] can be used, but not necessarily)
    • Shared messages (what if consumers build messages themselves after running extraction script?)
  • More docs for array-esque data (ref)
  • Docs about static analyzability
    • Calls to t (ref, related to above point)
    • No wrapping (ref)
    • We should also mention this for useTranslations. It works, but this has downsides (ref)
  • Double check PPR works for .po loader
  • SWC plugins are "experimental"
  • Autocomplete with type augmentation, but allow new messages (ref)
  • We should mention in docs that messages are read during build (this might be non-obvious).
  • Ask for more feedback
    • Node.js website team

Future explorations

  • How to migrate from hand-crafted keys to autogenerated ones (Codemod?)
  • A way to migrate catalogs when changing the format
  • Tool calls for get all missing translations / translate missing / etc.
  • A way to fix source text, i.e. pick a message by key and migrate it to a new message that is synced back into source code (e.g. with an editor, or could we also just watch the source catalog and automatically sync to source?)
  • Validation that extracted message for source locale matches source code
  • ESLint rule that checks that you're not using dynamic expressions with t
  • Provide supplemental descriptions for translations automatically via AI (related: Crowdin Context Harvester)
  • Conversion of ID-based projects? (contributions welcome)
  • Improve/add defaults
    • Detect srcPath automatically (like Tailwind)
    • Also all others could have defaults, but the question remains whether extraction remains opt-in
  • Rust-only version?

This list acts as my personal todo list that I want to share for transparency, but please be sure to comment here if you have feedback for the feature:

#2036

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions