I have a plugin where people can add their own (title) somewhere, but this title is not picked up by multilingual plugins.

Reason for that is that I'm not using the __() function of course, I'm just echoing the option value that the user has input.

For example echo esc_html( $my_title );

How can I make it translatable? Would echo esc_html__( $my_title, 'text-domain' ) work? I don't think so, I mean what would people see as the original string?

How WP would handle this?

1 Answer 1


No, you wouldn't use the translation functions (__(), _e() etc.). Those are for creating language files and must only be used on static strings. They need to be static because the tools for generating the language files don't execute PHP, so they can't process variables. They just parse the text of the code, essentially.

If you want to support multilingual plugins then you need to build that support in manually with whatever methods those plugins require. WordPress won't help you here. So you'll need to check the developer documentation of the multilingual plugins that you want to support. Here's some documentation for adding multilingual support for custom content for WPML, for example.

  • I also found this: wpml.org/forums/topic/translation-for-dynamic-value thanks : )
    – mrKC.988
    May 27, 2019 at 14:24
  • Well there you go. Just keep in mind that while WPML can use those functions to translate these dynamic strings, they won't work properly when creating language files. So if you are generating pot files, you'll want to exclude these instances. May 27, 2019 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.