Skip to content

[Feature] make-pot: Add extensions flag #466

Description

@michaelw85

Feature Request

Describe your use case and the problem you are facing

A while back support was added to pass extensions to the make-json command: #439 but the make-pot still has hardcoded extensions for JS extraction. https://github.com/wp-cli/i18n-command/blob/main/src/MakePotCommand.php#L672

Describe the solution you'd like

I want to be able to pass the TS extension to make-pot. A current workaround is to include a dist folder, but of course, it would be much nicer to have references to the actual code in the resulting pot file.

Activity

  1. swissspidy commented on Nov 6, 2025

    @swissspidy
    Member

    That would require use to support parsing TypeScript in PHP, which AFAIK isn't possible today. There is no such library capable of doing that. The library we use is strictly for ECMAScript (JS). That works for us because make-pot is primarily used for running against already built JS files in WordPress projects.

    If you want to extract strings from a TS codebase, I recommend using a different tool for that and then merging results with the ones from make-pot if needed.

  2. michaelw85 commented on Nov 6, 2025

    @michaelw85
    ContributorAuthor

    That would require use to support parsing TypeScript in PHP, which AFAIK isn't possible today. There is no such library capable of doing that. The library we use is strictly for ECMAScript (JS). That works for us because make-pot is primarily used for running against already built JS files in WordPress projects.

    If you want to extract strings from a TS codebase, I recommend using a different tool for that and then merging results with the ones from make-pot if needed.

    I was looking at the code, and thought it only did a readfile and scans plain text, but I just found the function scanner 🙈
    Since this isn't a simple request, which I thought it was, I will close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions