SUMMER SALE 2020!

30% OFF with coupon SUM30

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.

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.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