Setting up WordPress plugin
- To get started, open your WordPress admin page and proceed to Plugins > Add new.
- Download Lokalise Companion Plugin from Amazon S3 and install it by uploading ZIP file to WordPress.
- It is also advised to install WPML plugin that allows to manage multi-lingual content. Please note that is a third-party solution not maintained by Lokalise. We are planning to add support for more multi-lingual plugins in the future.
- Proceed to Settings > Lokalise.
- Copy the Authorization secret key.
- Next, proceed to your Lokalise project and open Settings > Integrations > Wordpress.
- Click Connect.
- Enter your Wordpress site hostname (for instance,
https://example.com) and the Lokalise secret obtained at step 5.
- Authorize Lokalise by pressing Accept.
Note for Apache users
If you are using the Apache web server, then it is required to update your
VirtualHost configuration for the authorization flow to work correctly. Specifically, add the following line:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
Then don't forget to restart your server.
Compatibility with other WordPress plugins
Lokalise integration might not work correctly with some other third-party plugins, especially with drag&drop site builders like WPBakery.
Linking posts and pages
After setting up the plugin, you will see content currently available in your Wordpress. To translate the content, you need to link it to the Lokalise project first. Linking effectively means importing content from Wordpress and creating new translation keys in Lokalise. These keys will then be properly linked to your WordPress content.
Note that you may filter the content using the dropdowns:
- Content type — posts or pages.
- Status — all, draft, or published.
Next, choose one or more items to link to your Lokalise project. Optionally, enable Create missing languages setting. If this option is enabled, all languages that are present in Wordpress but missing in your Lokalise project will be created automatically.
Finally, press Link items (or Link all items). You will see a small summary showing the imported languages and the number of affected keys.
If you need to link additional items later, press the Link more items button.
After the items are linked, you may proceed to the Lokalise project dashboard and edit the content as usual. All translations imported from Wordpress will have two tags:
- Tag named after the post or page. So, if the key belongs to the "Hello world" post, it will have a "Hello world" tag.
Managing linked items
Open Wordpress integration again to manage the currently linked items or link new ones. You will see the list of the currently linked items (note that are different fields):
The following actions are available:
- Export to Wordpress — load the items content from your Lokalise project to Wordpress. You will see a dialog box where you may choose one or more languages to export. Tick Don't export empty translations if you would like to skip loading translation keys with empty values.
- Import from Wordpress — load content from Wordpress to Lokalise. You will be presented with a dialog box allowing to choose one or more languages. If you enable the Overwrite updated translations option, then all your translations modified in Lokalise will be replaced with the values from the Wordpress.
- Unlink — remove the link between the chosen items and translation keys in your Lokalise project.
So, press Export to Wordpress, then return to your Wordpress and make sure the chosen items were updated properly!