diff --git a/blocks/eventi/block.json b/blocks/eventi/block.json index c5de3e9..c82b38b 100644 --- a/blocks/eventi/block.json +++ b/blocks/eventi/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "piazza-in-festa/eventi", - "version": "1.1.0", + "version": "1.2.0", "title": "Piazza in Festa", "category": "widgets", "icon": "calendar-alt", @@ -26,7 +26,8 @@ "dal": { "type": "string", "default": "" }, "al": { "type": "string", "default": "" }, "cerca": { "type": "string", "default": "" }, - "font": { "type": "string", "default": "" } + "font": { "type": "string", "default": "" }, + "lingua": { "type": "string", "default": "" } }, "editorScript": "file:./index.js" } diff --git a/blocks/eventi/index.js b/blocks/eventi/index.js index 3307ca3..83fa6d0 100644 --- a/blocks/eventi/index.js +++ b/blocks/eventi/index.js @@ -143,6 +143,23 @@ } }), campo('colore', __('Accent colour', 'piazza-in-festa'), __('Hex code, for instance #b4315a.', 'piazza-in-festa')), + el(SelectControl, { + label: __('Language', 'piazza-in-festa'), + help: __('Event texts are shown translated when a translation is available.', 'piazza-in-festa'), + value: a.lingua, + options: [ + { label: __('Same as the site', 'piazza-in-festa'), value: '' }, + { label: 'Italiano', value: 'it' }, + { label: 'English', value: 'en' }, + { label: 'Deutsch', value: 'de' }, + { label: 'Français', value: 'fr' } + ], + __next40pxDefaultSize: true, + __nextHasNoMarginBottom: true, + onChange: function (v) { + set({ lingua: v }); + } + }), el(SelectControl, { label: __('Font', 'piazza-in-festa'), value: a.font, diff --git a/includes/render.php b/includes/render.php index 3edf2b7..2876511 100644 --- a/includes/render.php +++ b/includes/render.php @@ -29,6 +29,7 @@ function pinfesta_defaults() { 'al' => '', 'cerca' => '', 'font' => '', + 'lingua' => '', ); } @@ -135,6 +136,25 @@ function pinfesta_build_url( $args ) { $query['cerca'] = mb_substr( $cerca, 0, 40 ); } + // Language of the widget: event texts (when translated), labels and links. + // Empty means "follow the site": the current locale, which multilingual + // plugins such as WPML or Polylang switch page by page. The service speaks + // Italian, English, German and French; any other language gets English, + // which a foreign visitor reads better than Italian. + $lingua = sanitize_key( (string) $args['lingua'] ); + + if ( '' === $lingua ) { + $lingua = substr( function_exists( 'determine_locale' ) ? determine_locale() : get_locale(), 0, 2 ); + } + + if ( ! in_array( $lingua, array( 'it', 'en', 'de', 'fr' ), true ) ) { + $lingua = 'en'; + } + + if ( 'it' !== $lingua ) { + $query['lingua'] = $lingua; + } + // The widget lives in an iframe and cannot inherit the site's font: the // service offers a few safe stacks to pick from. if ( in_array( $args['font'], array( 'helvetica', 'serif' ), true ) ) { diff --git a/includes/shortcode.php b/includes/shortcode.php index 55b5d28..16bcb69 100644 --- a/includes/shortcode.php +++ b/includes/shortcode.php @@ -9,6 +9,7 @@ * [piazza-in-festa comuni="alba,barolo,la-morra" limite="5"] * [piazza-in-festa regione="Piemonte" categoria="sagra_enogastronomica,mercatini"] * [piazza-in-festa regione="Veneto" categoria="mercatini" cerca="natale" dal="2026-11-01" al="2027-01-06"] + * [piazza-in-festa comuni="alba" lingua="en"] (default: the language of the site) * * @package PiazzaInFesta */ diff --git a/languages/piazza-in-festa-it_IT.po b/languages/piazza-in-festa-it_IT.po index 0537654..00fe555 100644 --- a/languages/piazza-in-festa-it_IT.po +++ b/languages/piazza-in-festa-it_IT.po @@ -174,3 +174,12 @@ msgstr "Carattere" msgid "Visitor device font" msgstr "Carattere del dispositivo del visitatore" + +msgid "Language" +msgstr "Lingua" + +msgid "Event texts are shown translated when a translation is available." +msgstr "I testi degli eventi compaiono tradotti quando c'è una traduzione." + +msgid "Same as the site" +msgstr "Quella del sito" diff --git a/languages/readme-it_IT.po b/languages/readme-it_IT.po index 864c3f5..0e3cfe8 100644 --- a/languages/readme-it_IT.po +++ b/languages/readme-it_IT.po @@ -95,8 +95,8 @@ msgid "As with any embedded content, that request reaches the service with the v msgstr "Come per qualsiasi contenuto incorporato, quella richiesta arriva al servizio con l'indirizzo IP del visitatore e lo user agent del browser. Il plugin non manda niente dal tuo server, non conserva niente sui tuoi visitatori e non usa cookie propri." #. Found in description paragraph. -msgid "When a visitor opens a page that contains the block or the shortcode, their browser loads a page from https://piazzainfesta.it/embed with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well." -msgstr "Quando un visitatore apre una pagina che contiene il blocco o lo shortcode, il suo browser carica una pagina da https://piazzainfesta.it/embed con i parametri che hai configurato: i comuni o la regione, le categorie, l'eventuale periodo e la parola nel titolo, quanti eventi mostrare e le opzioni di aspetto (tema, colore, carattere, titolo). Se hai salvato una chiave del servizio nelle impostazioni, anche la chiave fa parte di quell'indirizzo." +msgid "When a visitor opens a page that contains the block or the shortcode, their browser loads a page from https://piazzainfesta.it/embed with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, the language, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well." +msgstr "Quando un visitatore apre una pagina che contiene il blocco o lo shortcode, il suo browser carica una pagina da https://piazzainfesta.it/embed con i parametri che hai configurato: i comuni o la regione, le categorie, l'eventuale periodo e la parola nel titolo, quanti eventi mostrare, la lingua e le opzioni di aspetto (tema, colore, carattere, titolo). Se hai salvato una chiave del servizio nelle impostazioni, anche la chiave fa parte di quell'indirizzo." #. Found in description paragraph. msgid "This plugin displays events served by Piazza in Festa, an external service run by the plugin author." diff --git a/piazza-in-festa.php b/piazza-in-festa.php index 173a701..af5b4df 100644 --- a/piazza-in-festa.php +++ b/piazza-in-festa.php @@ -3,7 +3,7 @@ * Plugin Name: Piazza in Festa * Plugin URI: https://piazzainfesta.it/widget * Description: Show the upcoming local events of the Italian towns you follow: village feasts, concerts, fairs, exhibitions. Shortcode and block, updated daily. - * Version: 1.1.0 + * Version: 1.2.0 * Requires at least: 6.5 * Requires PHP: 7.4 * Author: Piazza in Festa @@ -17,7 +17,7 @@ defined( 'ABSPATH' ) || exit; -define( 'PINFESTA_VERSION', '1.1.0' ); +define( 'PINFESTA_VERSION', '1.2.0' ); define( 'PINFESTA_FILE', __FILE__ ); define( 'PINFESTA_DIR', plugin_dir_path( __FILE__ ) ); define( 'PINFESTA_URL', plugin_dir_url( __FILE__ ) ); diff --git a/readme.txt b/readme.txt index 7b57b69..4191690 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: eventi, sagre, comuni, pro loco, turismo Requires at least: 6.5 Tested up to: 7.1 Requires PHP: 7.4 -Stable tag: 1.1.0 +Stable tag: 1.2.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -36,7 +36,7 @@ The plugin is free and complete: every option described here works, with or with This plugin displays events served by **Piazza in Festa**, an external service run by the plugin author. -When a visitor opens a page that contains the block or the shortcode, their browser loads a page from `https://piazzainfesta.it/embed` with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well. +When a visitor opens a page that contains the block or the shortcode, their browser loads a page from `https://piazzainfesta.it/embed` with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, the language, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well. As with any embedded content, that request reaches the service with the visitor's IP address and browser user agent. The plugin sends nothing from your server, stores nothing about your visitors, and sets no cookies of its own. @@ -90,6 +90,9 @@ You can set the theme (light or dark), the accent colour and the heading. The re == Changelog == += 1.2.0 = +* The widget speaks Italian, English, German and French: event texts are translated when a translation is available, and labels and links follow. By default it follows the language of the site, including multilingual sites with WPML or Polylang. + = 1.1.0 = * Several categories at once, comma separated in the shortcode. * Period filter (`dal`, `al`): only events that start between two dates, for a page about Christmas or the summer.