You need to use the internationalisation APIs, these let you swap out hardcoded strings for localised versions, e.g.
<p>Hello world</p>
versus:
<p><?php _e( 'Hello world', 'joes_plugin' ); ?></p>
Then, you can use .po
/.mo
/.pot
files to provide alternatives, e.g. a file with french translations, a file with russian etc.
You’ll need to declare your translation text domain in your theme/plugin ( joes_plugin
in the example above ), as well as the domain path so WP knows the folder to look in for translation files. You’ll also need to call load_plugin_textdomain
on the plugins_loaded
hook
Here’s the handbook for the Internationalisation API:
https://developer.wordpress.org/apis/handbook/internationalization/
And the page for plugins:
https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/
And for generating the localisation files themselves:
https://developer.wordpress.org/plugins/internationalization/localization/
Each of these is a huge subject in of themselves, so I recommend asking multiple new follow up questions about specific parts
Note that this API cannot be used to translate things in the database, and you should never pass dynamic variables into these APIs. For multilingual frontends, you will need a plugin