Skip to content

Commit 4498217

Browse files
committed
Fix translations
1 parent 68ff502 commit 4498217

10 files changed

+40
-21
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
All notable changes to this project will be documented in this file, per [the Keep a Changelog standard](http://keepachangelog.com/).
44

5+
## [0.4.0] - 2023-09-07
6+
7+
### Added
8+
9+
- Translation support.
10+
- Portuguese translation.
11+
512
## [0.3.0] - 2023-09-01
613

714
### Added
815

916
- 'Cover' and 'Quote' blocks to list of allowed blocks.
10-
- CODEOWNERS file
17+
- CODEOWNERS file.
1118

1219
### Fixed
1320

accordion-block.php

+24-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Plugin URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=plugin-uri
66
* Requires at least: 6.1
77
* Requires PHP: 7.4
8-
* Version: 0.3.0
8+
* Version: 0.4.0
99
* Author: Pixel Albatross
1010
* Author URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=author-uri
1111
* License: GPL-2.0-or-later
@@ -17,6 +17,13 @@
1717
* @package pixelalbatross/accordion-block
1818
*/
1919

20+
// If this file is called directly, abort.
21+
if ( ! defined( 'WPINC' ) ) {
22+
die;
23+
}
24+
25+
define( 'PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
26+
2027
/**
2128
* Registers the block using the metadata loaded from the `block.json` file.
2229
* Behind the scenes, it registers also all assets so they can be enqueued
@@ -26,28 +33,36 @@
2633
*/
2734
function pixelalbatross_accordion_block_init() {
2835

29-
$blocks = [
30-
'accordion',
31-
'accordion-item',
32-
];
36+
$block_json_files = glob( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'build/*/block.json' );
3337

34-
foreach ( $blocks as $block ) {
35-
$folder = sprintf( '%s/build/%s', __DIR__, $block );
36-
$block_type = register_block_type( $folder );
38+
foreach ( $block_json_files as $filename ) {
39+
40+
$block_folder = dirname( $filename );
41+
$block_type = register_block_type_from_metadata( $block_folder );
3742

3843
if ( ! empty( $block_type->editor_script_handles ) ) {
3944
foreach ( $block_type->editor_script_handles as $handle ) {
4045
wp_set_script_translations(
4146
$handle,
4247
'accordion-block',
43-
plugin_dir_path( __FILE__ ) . 'languages'
48+
PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'languages'
4449
);
4550
}
4651
}
4752
}
4853
}
4954
add_action( 'init', 'pixelalbatross_accordion_block_init' );
5055

56+
/**
57+
* Registers the block textdomain.
58+
*
59+
* @return void
60+
*/
61+
function pixelalbatross_accordion_block_i18n() {
62+
load_plugin_textdomain( 'accordion-block', false, plugin_basename( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH ) . '/languages' );
63+
}
64+
add_action( 'plugins_loaded', 'pixelalbatross_accordion_block_i18n' );
65+
5166
/**
5267
* Handles JavaScript detection.
5368
*

build/accordion-item/block.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"icon": "editor-table",
1111
"description": "Display content in collapsible sections.",
1212
"keywords": [],
13-
"version": "0.1.0",
1413
"textdomain": "accordion-block",
1514
"attributes": {
1615
"title": {

build/accordion/block.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"accordion",
1111
"collapse"
1212
],
13-
"version": "0.1.0",
1413
"textdomain": "accordion-block",
1514
"attributes": {},
1615
"supports": {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"translation-revision-date":"2023-09-07 01:36+0100","generator":"WP-CLI\/2.8.1","source":"build\/accordion-item\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"pt_PT","plural-forms":"nplurals=2; plural=(n != 1);"},"Accordion Title":["T\u00edtulo do acorde\u00e3o"],"Settings":["Configura\u00e7\u00f5es"],"Expand by default":["Expandir por omiss\u00e3o"],"When enabled, the item will be expanded by default on page load.":["Quando activado, o item ser\u00e1 expandido por omiss\u00e3o no carregamento da p\u00e1gina."]}}}
1+
{"translation-revision-date":"2023-09-07 02:03+0100","generator":"WP-CLI\/2.8.1","source":"build\/accordion-item\/index.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"pt_PT","plural-forms":"nplurals=2; plural=(n != 1);"},"Accordion Title":["T\u00edtulo do acorde\u00e3o"],"Settings":["Configura\u00e7\u00f5es"],"Expand by default":["Expandir por omiss\u00e3o"],"When enabled, the item will be expanded by default on page load.":["Quando activado, o item ser\u00e1 expandido por omiss\u00e3o no carregamento da p\u00e1gina."]}}}

languages/accordion-block-pt_PT.mo

-31 Bytes
Binary file not shown.

languages/accordion-block-pt_PT.po

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ msgid ""
22
msgstr ""
33
"Project-Id-Version: Accordion Block 0.3.0\n"
44
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/accordion-block\n"
5-
"POT-Creation-Date: 2023-09-07T00:21:35+00:00\n"
6-
"PO-Revision-Date: 2023-09-07 02:03+0100\n"
75
"Last-Translator: \n"
86
"Language-Team: \n"
9-
"Language: pt_PT\n"
107
"MIME-Version: 1.0\n"
118
"Content-Type: text/plain; charset=UTF-8\n"
129
"Content-Transfer-Encoding: 8bit\n"
10+
"POT-Creation-Date: 2023-09-07T00:21:35+00:00\n"
11+
"PO-Revision-Date: 2023-09-07 02:03+0100\n"
12+
"Language: pt_PT\n"
1313
"X-Generator: Poedit 3.3.2\n"
1414
"X-Domain: accordion-block\n"
1515

@@ -50,7 +50,8 @@ msgctxt "block title"
5050
msgid "Accordion Item"
5151
msgstr "Item de acordeão"
5252

53-
#: build/accordion-item/block.json build/accordion/block.json
53+
#: build/accordion-item/block.json
54+
#: build/accordion/block.json
5455
msgctxt "block description"
5556
msgid "Display content in collapsible sections."
5657
msgstr "Apresentar conteúdo em secções recolhíveis."

languages/accordion-block.pot

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This file is distributed under the GPL-2.0-or-later.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Accordion Block 0.3.0\n"
5+
"Project-Id-Version: Accordion Block 0.4.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/accordion-block\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <LL@li.org>\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2023-09-07T00:57:15+00:00\n"
12+
"POT-Creation-Date: 2023-09-07T18:15:02+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.8.1\n"
1515
"X-Domain: accordion-block\n"

src/accordion-item/block.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"icon": "editor-table",
1111
"description": "Display content in collapsible sections.",
1212
"keywords": [],
13-
"version": "0.1.0",
1413
"textdomain": "accordion-block",
1514
"attributes": {
1615
"title": {

src/accordion/block.json

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"accordion",
1111
"collapse"
1212
],
13-
"version": "0.1.0",
1413
"textdomain": "accordion-block",
1514
"attributes": {},
1615
"supports": {

0 commit comments

Comments
 (0)