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?
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?
Share Improve this question asked May 27, 2019 at 14:04 mrKC.988mrKC.988 1072 silver badges14 bronze badges1 Answer
Reset to default 1No, 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.