Wypo Logo Header@2x
Blog / Developer / How to translate your WordPress plugin?

How to translate your WordPress plugin?

Developer
Time to read : 12 minutes

Publication date: 21 July 2024

In an increasingly connected world, translating your WordPress plugin is no longer a simple option, but a necessity if you want to reach a global audience. Whether you’re an independent developer or a business looking to maximise the impact of your digital products, translating your plugin offers many benefits. In this article, we’ll explore in detail why and how to translate your WordPress plugin.

Why translate a plugin

Accessibility for a global audience

Increasing accessibility

Translating your plugin allows users in different parts of the world to understand and use your plugin in their native language. This greatly expands your potential user base.

Multilingual support

By offering translations, you improve the user experience for those who prefer or need interfaces in their own language, increasing user satisfaction and engagement.

Improving the user experience

Comfort and confidence

Users feel more comfortable and confident when interacting with a plugin in their own language. This reduces friction and errors, making use of the plugin more intuitive.

Ergonomics

A correctly translated interface is more ergonomic and makes it easier to understand and use the plugin’s features, which can lead to faster adoption and greater satisfaction.

Increase downloads and positive reviews

Extended scope

By making your plugin available in several languages, you broaden its appeal and increase downloads and installations. Greater accessibility potentially means more users.

Opinions and ratings

A better user experience often translates into more positive reviews and ratings. This positive feedback can improve the visibility and credibility of your plugin on the market.

Market competitiveness

Stand out from the crowd

In a market saturated with plugins, a multilingual plugin stands out as being more professional and attentive to the needs of international users. This can help you stand out from the competition.

Competitive advantage

Translation offers a competitive advantage, especially if your competitors have not yet translated their plugins. You can capture additional market share.

Compliance and standardisation

Compliance with standards

Many companies and organisations have internal policies requiring software to be available in several languages to meet the needs of their employees or customers.

Best practices

The translation is in line with the best practices recommended by WordPress for plugin developers, helping you to maintain high standards of quality and accessibility.

Contributing to the WordPress community

Community involvement

By providing translations, you are contributing to WordPress’ mission of making the web accessible to everyone, regardless of language. It’s a way of giving back to the WordPress community.

Collaboration and sharing

You can work with volunteer translators and community members to improve the translations and accessibility of your plugin, thereby strengthening community links.

SEO multilingue

Improving referencing

Translating your plugin can improve your multilingual SEO, attracting more organic traffic from search engines in different languages. This can increase your visibility and your audience.

User engagement

Commitment and loyalty

Users are more likely to remain engaged and loyal to a plugin that they can use in their native language. This can improve user retention and long-term loyalty.

How to translate your WordPress plugin

Preparing the plugin for translation

Utilisez les fonctions de traduction WordPress comme __(), _e(), _n(), et esc_html__(). Il est recommandé d’utiliser ces fonctions dès le début du développement pour éviter d’adapter tout le plugin en fin de développement.

Add a unique, plugin-specific text domain to each translation function in your plugin. This helps WordPress to identify and load translations correctly.

For example:

PHP

Create the .pot file

You can use a tool like Poedit or a WordPress plugin like Loco Translate to create a .pot file (Portable Object Template).

With Poedit:

  • Download and install Poedit.
  • Open Poedit and select ‘Create a new source catalogue’.
  • Configure the project properties by entering the text domain and other relevant information.
  • Add the source files for your plugin.
  • Save the .pot file in your plugin’s languages folder (for example, my-plugin/languages/my-plugin.pot).

It is advisable to update the .pot file gradually during the development of your plugin. This way, you avoid having to enter all the translations at once at the end and the risk of forgetting certain strings, while avoiding having to process all the PHP files at the same time.

Translate the plugin

Create .po and .mo translation files:

  • Use Poedit or Loco Translate to create .po files for each language you wish to support.
  • Translate the text strings in Poedit.
  • Save the .po files and Poedit will automatically generate the corresponding .mo files.
  • The translation files should be named using the language code and text domain, for example: my-plugin-fr_FR.po and my-plugin-fr_FR.mo for French.

In the package (shared folder) for your plugin, you can keep only the .mo files. These binary files are sufficient for WordPress to load the necessary translations, which reduces the clutter of the folder by excluding the .po and .pot source files, while ensuring that the translations work correctly for end users.

Loading translations into your plugin

Add code to your plugin’s main file to load the translation files.

PHP
Last 30 days : 1
Total : 242