How get Make-Pot to work with typescript ts, tsx files

TLDR;
No you cannot. The WP-Cli command is a php script and relies on a external parser to parse javascript. And after year the parser hasn’t been updated to support “new” js dialects so i decided to write my own.

Here how it was gone!

Introducing Make Pot: Simplifying WordPress Plugin and Theme Internationalization

Internationalization is a crucial aspect of WordPress development, allowing plugins and themes to be translated into various languages. Traditionally, developers have relied on tools like the make-pot command in the WP CLI to generate the essential .pot file, which serves as the foundation for translation efforts. However, a new contender has emerged in the form of a Node.js module called Make Pot, aiming to streamline and enhance this process.

Make Pot isn’t just another tool; it brings several key improvements to the table that make internationalization more accessible and efficient for developers. Let’s delve into its standout features:

1. Expanded Language Support:

Make Pot supports a wider range of programming languages compared to its predecessors. With compatibility extending to TypeScript (.ts, .tsx)

and more, developers can internationalize their projects regardless of the language used. Additionally, Make Pot intelligently handles comments related to links and translators, ensuring they are appropriately handled during the internationalization process.

2. Seamless Integration via npm:
As an npm module, Make Pot offers effortless integration into existing build chains for WordPress plugins and themes. By simply adding Make Pot to the build process, developers can automate the generation of .pot files, saving time and streamlining their workflow.

Using Make Pot in Your Project:

To incorporate Make Pot into your WordPress development workflow, follow these steps:

  1. Installation:
    Install Make Pot globally using npm:
   npm install -g @wp-blocks/make-pot
  1. Usage:
    Utilize Make Pot to extract strings from your plugin or theme and generate a .pot file. The command syntax is as follows:
   npx @wp-blocks/make-pot [sourceDirectory] [destination] [options]
  1. As a Build Chain Step:
    Integrate Make Pot into your build chain by defining a build:makepot action in your package.json. Customize the action according to your project’s needs using the available options.
{
  "build:makepot": "npx @wp-blocks/make-pot [sourceDirectory] [destination] [options]"
}

With Make Pot, internationalizing your WordPress projects becomes more straightforward and versatile than ever before. Embrace the power of Make Pot to ensure your plugins and themes resonate with a global audience, breaking language barriers and fostering inclusivity in the WordPress ecosystem.

Post navigation

You might be interested in...

No comments yet, be the first!

Comments

Your email address will not be published. Required fields are marked *