| [ Web Proxy ] |
| Viewing: https://docs.metabox.io/integrations/polylang/ | [Back] [Original] |
Integration with Polylang offers an intuitive interface to translate both values and labels of all objects, including post types, taxonomies, custom fields, settings pages, and relationships. It works smoothly whether you're using Polylang or Polylang Pro.
Especially, the UI for translating Meta Box field values is the standout feature of this integration, instead of using the wpml-config.xml file as Polylang documentation.
After installing Polylang on your site, the setup wizard is automatically launched with all the necessary steps to configure easily a multilingual website.
In there, two of the most essential setup steps are the site languages and the menus.
In the case that you skip the setup wizard, go to Languages > Setup to add the languages for your site. Then, you should define at least one language by choosing from a list of over 90 predefined languages or creating a custom one. The first language you add becomes the default language of your multilingual website.
On this screen, you also can configure media, content, and homepage in the next steps. Click on the Continue button to set them up.
This focuses on displaying and customizing the switch language button on the frontend.
Go to Appearance > Menus, then follow these steps:
[Set up the language switcher menu]
Note that the language switcher will display a language only if at least one post or one page has been published in this language.
If you havent seen the switcher on the frontend, save your change in the Manage Locations tab.
Each Meta Box object includes the value (data) and label (configuration). Meta Box - Polylang integration allows you to translate both of them.
In terms of labels, you can input translations directly without any additional configuration. They are strings in the Translations table already. For convenience, Meta Box provides filters based on objects along with their name, as you can see below:
[Meta Box provides filters based on objects to translate labels easily]
So, you can translate labels of post types, taxonomies, fields/field groups, and settings page. You should use them to avoid missing any labels instead of using the search bar.
Labels must have a value in order to be translated (for example: The Add more text of a cloneable field or custom submit button of a settings page). If the label is empty or not set, the translation feature will be skipped for that label.
To translate values, depending on the object you want to translate, there will be corresponding translation methods:
To display translation on the frontend, you can use MB Views, a page builder or code.
For example, I created a post type named Events. Now, our goal is to translate its labels and posts.
Go to Languages > Translations. Then, find the Meta Box Post Type option with the name you want from the dropdown list, and click Filter to have all the labels of that post type. Simply enter the translations one by one.
[Filter by Meta Box Post type to translate post type labels]
After saving the changes, the translation updated immediately.
[The translations of post type labels are displayed]
First, you need to activate languages and translations for the custom post type.
Go to Languages > Settings. Then, click on the Settings button in the Custom post types and Taxonomies option to activate the translations feature for it.
[Activate languages and translations for the custom post type]
After that, go to the post editor to enter the translation for posts. There is a section named Languages on the right panel. You can enter the title translation into the box, or click on the + button to switch to the post in the corresponding language and input the translation of the title and description of the post.
[Click on the + button to input the translation for the posts]
The icon will be changed to Edit when that language has the translation version.
Now, in the post type admin, that translation is displayed when you switch the language.
[The translation of posts is displayed]
Translating custom taxonomy labels and values is the same as translating post types.
In the Translation submenu, filter strings by Meta Box Taxonomy. Then, just switch the language in the top bar and enter translation for labels one by one.
[Filter by Meta Box taxonomy to translate taxonomy labels]
After saving translations, you can see they are output like this:
[The translations of taxonomy labels are displayed]
To translate terms of taxonomy, you need to activate languages and translations of that taxonomy and the post type that the taxonomy is assigned to.
They are all located in the Custom post types and Taxonomies option.
[Activate languages and translations for the custom post type and taxonomy]
Then, in the taxonomy admin, you have two positions to add translations for the term like this:
[Input translations for terms]
Meta Box - Polylang integration allows you to translate labels easily, including field group name, field label, label description, input description, default value, placeholder, and adding more text of cloneable field/group.
Assuming that we need to translate these labels:
[The field labels need to translate]
Navigate to Languages > Translations. In the list of filters, you can see Meta Box Field Group. In this case, I set the language as Show all languages to fill in the translations for all languages at the same time.
[Filter by Meta Box Field group to translate field labels]
Go to the post editor, you can see the translation of field labels.
[The translations of field labels are displayed]
Instead of editing the wpml-config.xml file manually as previously, you can now translate field values and manage translations directly with a user-friendly interface. Translating is easy for both developers and non-developers.
Right in the Settings tab of the field group, there is a new setting named Translation, along with 4 options:
[The translation setting offers options to translate the field group]
When you choose the fourth option, a pop-up includes all the fields and groups with three translation methods:
[Choose the translation mode for each field]
translate, the Meta Box Polylang integration will copy the ID of the original object instead of linking to its translated version.If you use code, you can also translate the values of fields and field groups. Just add the translation property, which supports the following values (corresponding translation mode with UI):
ignore: The field group/field value will be left blank in the newly created translation.translate: The value will be copied and can be edited.copy: The value will be synced to all translationsadvanced: Enable custom translation settings for each field.For example, to translate the address field, the code as below:
[Translate field values using code]
Then, the field in the post editor is ready for enter the translation with the default value as the field value of the default language.
[Enter the translation for the values]
Similar to translating labels of other objects, this integration helps you filter and translate the settings page labels quickly.
Go to the Translation submenu, then filter strings by Meta Box Settings Page:
[Filter by Meta Box Settings Page to translate settings page labels]
Even when you have custom fields on the settings page, the Meta Box - Polylang integration works well for translating field labels. Also, filter by Meta Box Field Group to enter translations for them.
[Filter by Meta Box Field group to translate settings page field labels]
In the settings page, all the labels are switched to the corresponding language seamlessly.
[The translations of setting page labels are displayed]
Translating field values in the settings page is simplest since you can enter the translation directly without any additional configuration.
[Translate values of settings page fields]
Besides, you can still filter strings by MB Settings Page in the Translation table as other labels.
[Filter by MB Settings Page to translate settings page field values]
When you delete a value from one language on the settings page, the values from other languages are auto-deleted. It happens with not only the Meta Box settings page but also WordPress settings (For instance, site title or site description in General settings)
In the Translations submenu, filter strings by Meta Box Relationship to input the translation for the relationship labels:
[Translate relationship labels]
Then, in the post editor, they transfer well when you change the language
| Web Proxy Viewer | New URL | Original Page |