Skip to content

Stabilize useExtracted #2087

@amannn

Description

@amannn

With [email protected], 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

  • Open-source PO parser so custom po formatters are easy to build (ref) --> fix: Move implementation of POParser to po-parser #2113
  • Wiped out target locales (ref)
  • Check / fix source maps (see also magic-string)
  • Custom formatters for use cases:
    • PO with source as ID
    • Auto-population for pseudo locale
    • Custom JSON
  • Rename "formatter" to something like "adapter" 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

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
  • 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