Multilingual

←  All Add-Ons

This add-on adds support for Polylang and WPML plugins. WP Grid Builder natively works with Polylang and WPML plugins. However, it requires to create grids, cards and facets for each language (like for posts).

With this add-on, grids and facets will be queried in the right language in your pages. It means that you only need to create one grid, facet or card to handle all languages defined on your site. And, you will be able to globally translate all strings of WP Grid Builder directly from Polylang and WPML interfaces.

Key features

  • Automatically query grids and facets in current language
  • Support strings translation in Polylang plugin
  • Support strings translation in WPML plugin

Usage

Once the add-on activated, all your grids and facets will display the right translated content in your pages. Moreover, you will be able to translate all strings generated by WP Grid Builder from Polylang Strings Translations panel or WPML String Translation panel.

In order to correctly index facets in all languages, it is necessary to create posts/terms in each language. Posts and terms must exist and not simply be translated at string level. Without this, it is not possible to index all languages.

Screenshots

Polylang - Strings Translation
Polylang – Strings Translation
WPML - Strings Translation
WPML – Strings Translation

Documentation

This add-on comes with several PHP filters to easily register strings for developers or to translate/modify strings.

To dynamically modify a translatable string you can use this PHP filter:

PHP
functions.php
function prefix_translate_string( $string, $slug, $context, $domain, $lang ) {

	if ( 'fr' === $lang && 'My string' === $string ) {
		$string = 'My translated string';
	}

	return $string;

}

add_filter( 'wp_grid_builder_i18n/translate_string', 'prefix_translate_string', 10, 5 );

Under certain cases, you may need to translate empty strings. Because depending of the language, a suffix or a prefix for example, will not have the same meaning. In this case, you can target which content and string slug to translate.

Here an example of how to translate Range facet prefix and suffix. In our case we want to change dollars sign (prefix) to euro sign (suffix) in French:

PHP
functions.php
function prefix_translate_string( $string, $slug, $context, $domain, $lang ) {

	// If it's not French language or not facet string.
	if ( 'fr' !== $lang || 'facet' !== $context ) {
		return $string;
	}

	// We set range facet suffix (which is currently empty).
	if ( 'suffix' === $slug ) {
		$string = '€';
	// We remove the $ sign prefix used for English language.
	} elseif ( 'prefix' === $slug ) {
		$string = '';
	}

	return $string;

}

add_filter( 'wp_grid_builder_i18n/translate_string', 'prefix_translate_string', 10, 5 );

This add-on also provides a way to register strings. It is mainly focused for developers that creates features or add-ons for WP Grid Builder and introduce new translatable strings in grid/card/facet settings. For example, we use the following filters to register new strings from our add-ons.

To register strings for a grid you can use this PHP filter:

PHP
functions.php
function prefix_register_strings( $registry ) {

	$registry['my_string_slug'] = [
		'domain'    => 'Gridbuilder ᵂᴾ',
		'multiline' => true,
	];

	return $registry;

}

add_filter( 'wp_grid_builder_i18n/grid/register_strings', 'prefix_register_strings' );

The same can be done for card and facet strings thanks to these filters:

PHP
functions.php
add_filter( 'wp_grid_builder_i18n/card/register_strings', 'prefix_register_strings' );
add_filter( 'wp_grid_builder_i18n/facet/register_strings', 'prefix_register_strings' );

Changelog

v1.1.2

Release date: September 5, 2022

  • fixedIssue with translations in the selection facet.

v1.1.1

Release date: May 2, 2022

  • fixedIssue with string translations in ACF repeater.
  • fixedIssue with translations in ACF choices.

v1.1.0

Release date: February 11, 2022

  • fixedIssue with translations of facet choice strings.
  • fixedIssue with parent/included/excluded taxonomy terms in facets.

v1.0.8

Release date: October 6, 2021

  • fixedIssue with WPML and language parameter.

v1.0.7

Release date: October 5, 2021

  • fixedIssue with translated tax_query parameter of the grid query.

v1.0.6

Release date: April 7, 2021

  • fixedIssue with included and excluded terms in facet settings.

v1.0.5

Release date: November 5, 2020

  • fixedIssue with grid strings not correctly registered in WPML and Polylang.

v1.0.4

Release date: October 19, 2020

  • addedCompatibility with Elementor.

v1.0.3

Release date: June 16, 2020

  • fixedSlow query when filtering with Polylang.

v1.0.2

Release date: April 14, 2020

  • addedFrench translation.

v1.0.1

Release date: March 25, 2020

  • fixedIssue with WPML lang query string parameter if default language.

v1.0.0

Release date: February 10, 2020

  • releasedPublic Release