Skip to content

Commit

Permalink
Fix translations
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rgiosan committed Sep 7, 2023
1 parent 68ff502 commit 4498217
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 21 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

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

## [0.4.0] - 2023-09-07

### Added

- Translation support.
- Portuguese translation.

## [0.3.0] - 2023-09-01

### Added

- 'Cover' and 'Quote' blocks to list of allowed blocks.
- CODEOWNERS file
- CODEOWNERS file.

### Fixed

Expand Down
33 changes: 24 additions & 9 deletions accordion-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=plugin-uri
* Requires at least: 6.1
* Requires PHP: 7.4
* Version: 0.3.0
* Version: 0.4.0
* Author: Pixel Albatross
* Author URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=author-uri
* License: GPL-2.0-or-later
Expand All @@ -17,6 +17,13 @@
* @package pixelalbatross/accordion-block
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

define( 'PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );

/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
Expand All @@ -26,28 +33,36 @@
*/
function pixelalbatross_accordion_block_init() {

$blocks = [
'accordion',
'accordion-item',
];
$block_json_files = glob( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'build/*/block.json' );

foreach ( $blocks as $block ) {
$folder = sprintf( '%s/build/%s', __DIR__, $block );
$block_type = register_block_type( $folder );
foreach ( $block_json_files as $filename ) {

$block_folder = dirname( $filename );
$block_type = register_block_type_from_metadata( $block_folder );

if ( ! empty( $block_type->editor_script_handles ) ) {
foreach ( $block_type->editor_script_handles as $handle ) {
wp_set_script_translations(
$handle,
'accordion-block',
plugin_dir_path( __FILE__ ) . 'languages'
PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'languages'
);
}
}
}
}
add_action( 'init', 'pixelalbatross_accordion_block_init' );

/**
* Registers the block textdomain.
*
* @return void
*/
function pixelalbatross_accordion_block_i18n() {
load_plugin_textdomain( 'accordion-block', false, plugin_basename( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH ) . '/languages' );
}
add_action( 'plugins_loaded', 'pixelalbatross_accordion_block_i18n' );

/**
* Handles JavaScript detection.
*
Expand Down
1 change: 0 additions & 1 deletion build/accordion-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"icon": "editor-table",
"description": "Display content in collapsible sections.",
"keywords": [],
"version": "0.1.0",
"textdomain": "accordion-block",
"attributes": {
"title": {
Expand Down
1 change: 0 additions & 1 deletion build/accordion/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"accordion",
"collapse"
],
"version": "0.1.0",
"textdomain": "accordion-block",
"attributes": {},
"supports": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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."]}}}
{"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."]}}}
Binary file modified languages/accordion-block-pt_PT.mo
Binary file not shown.
9 changes: 5 additions & 4 deletions languages/accordion-block-pt_PT.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ msgid ""
msgstr ""
"Project-Id-Version: Accordion Block 0.3.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/accordion-block\n"
"POT-Creation-Date: 2023-09-07T00:21:35+00:00\n"
"PO-Revision-Date: 2023-09-07 02:03+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pt_PT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-09-07T00:21:35+00:00\n"
"PO-Revision-Date: 2023-09-07 02:03+0100\n"
"Language: pt_PT\n"
"X-Generator: Poedit 3.3.2\n"
"X-Domain: accordion-block\n"

Expand Down Expand Up @@ -50,7 +50,8 @@ msgctxt "block title"
msgid "Accordion Item"
msgstr "Item de acordeão"

#: build/accordion-item/block.json build/accordion/block.json
#: build/accordion-item/block.json
#: build/accordion/block.json
msgctxt "block description"
msgid "Display content in collapsible sections."
msgstr "Apresentar conteúdo em secções recolhíveis."
Expand Down
4 changes: 2 additions & 2 deletions languages/accordion-block.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPL-2.0-or-later.
msgid ""
msgstr ""
"Project-Id-Version: Accordion Block 0.3.0\n"
"Project-Id-Version: Accordion Block 0.4.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/accordion-block\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-09-07T00:57:15+00:00\n"
"POT-Creation-Date: 2023-09-07T18:15:02+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.8.1\n"
"X-Domain: accordion-block\n"
Expand Down
1 change: 0 additions & 1 deletion src/accordion-item/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"icon": "editor-table",
"description": "Display content in collapsible sections.",
"keywords": [],
"version": "0.1.0",
"textdomain": "accordion-block",
"attributes": {
"title": {
Expand Down
1 change: 0 additions & 1 deletion src/accordion/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"accordion",
"collapse"
],
"version": "0.1.0",
"textdomain": "accordion-block",
"attributes": {},
"supports": {
Expand Down

0 comments on commit 4498217

Please sign in to comment.