Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(i18n): Make strings translatable and generate .pot file #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions assets/block-extensions/aos-animation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';
import { PanelBody, SelectControl, RangeControl, ToggleControl } from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';

// Specify allowed blocks to which the attributes should be added
const allowedBlocks = [
Expand Down Expand Up @@ -56,63 +57,63 @@ const withInspectorControls = createHigherOrderComponent((BlockEdit) => {
<>
<BlockEdit {...props} />
<InspectorControls>
<PanelBody title="Animation Settings" initialOpen={true}>
<PanelBody title={__('Animation Settings', 'kindling')} initialOpen={true}>
<SelectControl
label="Select Animation"
label={__('Select Animation', 'kindling')}
value={attributes.animation}
options={[
{ label: 'None', value: '' },
{ label: 'Fade', value: 'fade' },
{ label: 'Fade Up', value: 'fade-up' },
{ label: 'Fade Down', value: 'fade-down' },
{ label: 'Fade Left', value: 'fade-left' },
{ label: 'Fade Right', value: 'fade-right' },
{ label: 'Fade Up Right', value: 'fade-up-right' },
{ label: 'Fade Up Left', value: 'fade-up-left' },
{ label: 'Fade Down Right', value: 'fade-down-right' },
{ label: 'Fade Down Left', value: 'fade-down-left' },
{ label: 'Flip Up', value: 'flip-up' },
{ label: 'Flip Down', value: 'flip-down' },
{ label: 'Flip Left', value: 'flip-left' },
{ label: 'Flip Right', value: 'flip-right' },
{ label: 'Slide Up', value: 'slide-up' },
{ label: 'Slide Down', value: 'slide-down' },
{ label: 'Slide Left', value: 'slide-left' },
{ label: 'Slide Right', value: 'slide-right' },
{ label: 'Zoom In', value: 'zoom-in' },
{ label: 'Zoom In Up', value: 'zoom-in-up' },
{ label: 'Zoom In Down', value: 'zoom-in-down' },
{ label: 'Zoom In Left', value: 'zoom-in-left' },
{ label: 'Zoom In Right', value: 'zoom-in-right' },
{ label: 'Zoom Out', value: 'zoom-out' },
{ label: 'Zoom Out Up', value: 'zoom-out-up' },
{ label: 'Zoom Out Down', value: 'zoom-out-down' },
{ label: 'Zoom Out Left', value: 'zoom-out-left' },
{ label: 'Zoom Out Right', value: 'zoom-out-right' }
{ label: __('None', 'kindling'), value: '' },
{ label: __('Fade', 'kindling'), value: 'fade' },
{ label: __('Fade Up', 'kindling'), value: 'fade-up' },
{ label: __('Fade Down', 'kindling'), value: 'fade-down' },
{ label: __('Fade Left', 'kindling'), value: 'fade-left' },
{ label: __('Fade Right', 'kindling'), value: 'fade-right' },
{ label: __('Fade Up Right', 'kindling'), value: 'fade-up-right' },
{ label: __('Fade Up Left', 'kindling'), value: 'fade-up-left' },
{ label: __('Fade Down Right', 'kindling'), value: 'fade-down-right' },
{ label: __('Fade Down Left', 'kindling'), value: 'fade-down-left' },
{ label: __('Flip Up', 'kindling'), value: 'flip-up' },
{ label: __('Flip Down', 'kindling'), value: 'flip-down' },
{ label: __('Flip Left', 'kindling'), value: 'flip-left' },
{ label: __('Flip Right', 'kindling'), value: 'flip-right' },
{ label: __('Slide Up', 'kindling'), value: 'slide-up' },
{ label: __('Slide Down', 'kindling'), value: 'slide-down' },
{ label: __('Slide Left', 'kindling'), value: 'slide-left' },
{ label: __('Slide Right', 'kindling'), value: 'slide-right' },
{ label: __('Zoom In', 'kindling'), value: 'zoom-in' },
{ label: __('Zoom In Up', 'kindling'), value: 'zoom-in-up' },
{ label: __('Zoom In Down', 'kindling'), value: 'zoom-in-down' },
{ label: __('Zoom In Left', 'kindling'), value: 'zoom-in-left' },
{ label: __('Zoom In Right', 'kindling'), value: 'zoom-in-right' },
{ label: __('Zoom Out', 'kindling'), value: 'zoom-out' },
{ label: __('Zoom Out Up', 'kindling'), value: 'zoom-out-up' },
{ label: __('Zoom Out Down', 'kindling'), value: 'zoom-out-down' },
{ label: __('Zoom Out Left', 'kindling'), value: 'zoom-out-left' },
{ label: __('Zoom Out Right', 'kindling'), value: 'zoom-out-right' },
]}
onChange={(animation) => setAttributes({ animation })}
/>
<SelectControl
label="Easing"
label={__('Easing', 'kindling')}
value={attributes.aosEasing}
options={[
{ label: 'Ease', value: 'ease' },
{ label: 'Ease In', value: 'ease-in' },
{ label: 'Ease Out', value: 'ease-out' },
{ label: 'Ease In Out', value: 'ease-in-out' },
{ label: 'Linear', value: 'linear' },
{ label: __('Ease', 'kindling'), value: 'ease' },
{ label: __('Ease In', 'kindling'), value: 'ease-in' },
{ label: __('Ease Out', 'kindling'), value: 'ease-out' },
{ label: __('Ease In Out', 'kindling'), value: 'ease-in-out' },
{ label: __('Linear', 'kindling'), value: 'linear' },
]}
onChange={(aosEasing) => setAttributes({ aosEasing })}
/>
<RangeControl
label="Duration (ms)"
label={__('Duration (ms)', 'kindling')}
value={attributes.aosDuration}
onChange={(aosDuration) => setAttributes({ aosDuration })}
min={0}
max={5000}
/>
<RangeControl
label="Delay (ms)"
label={__('Delay (ms)', 'kindling')}
value={attributes.aosDelay}
onChange={(aosDelay) => setAttributes({ aosDelay })}
min={0}
Expand Down
17 changes: 9 additions & 8 deletions assets/block-extensions/box-shadow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RadioControl } from '@wordpress/components';
import { InspectorAdvancedControls } from '@wordpress/block-editor';
import { createHigherOrderComponent } from '@wordpress/compose';
import { addFilter } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';

const blocksWithBoxShadow = [ 'core/group', 'core/column', 'core/cover' ];

Expand Down Expand Up @@ -56,16 +57,16 @@ export const shadowAdvancedControls = createHigherOrderComponent((BlockEdit) =>
{isSelected && (blocksWithBoxShadow.includes( props.name )) &&
<InspectorAdvancedControls>
<RadioControl
label="Box Shadow"
help="The size of the box shadow"
label={__('Box Shadow', 'kindling')}
help={__('The size of the box shadow', 'kindling')}
selected={ boxShadow }
options={[
{ label: 'None', value: 'none' },
{ label: 'X-Small', value: 'xs' },
{ label: 'Small', value: 'sm' },
{ label: 'Medium', value: 'md' },
{ label: 'Large', value: 'large' },
] }
{ label: __('None', 'kindling'), value: 'none' },
{ label: __('X-Small', 'kindling'), value: 'xs' },
{ label: __('Small', 'kindling'), value: 'sm' },
{ label: __('Medium', 'kindling'), value: 'md' },
{ label: __('Large', 'kindling'), value: 'large' },
]}
onChange={(value) => setAttributes({ boxShadow: String(value) }) }
/>
</InspectorAdvancedControls>
Expand Down
12 changes: 6 additions & 6 deletions assets/block-extensions/components/url-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ const URLInput = ( {
const advancedOptions = (
<>
<ToggleControl
label={ __( 'Open in New Tab', 'block-options' ) }
label={ __( 'Open in New Tab', 'kindling' ) }
onChange={ onSetNewTab }
checked={ opensInNewTab }
/>
<ToggleControl
label={ __( 'No Follow', 'block-options' ) }
label={ __( 'No Follow', 'kindling' ) }
onChange={ onSetLinkNoFollow }
checked={ linkNoFollow }
/>
<ToggleControl
label={ __( 'Sponsored', 'block-options' ) }
label={ __( 'Sponsored', 'kindling' ) }
onChange={ onSetLinkSponsored }
checked={ linkSponsored }
/>
Expand All @@ -140,8 +140,8 @@ const URLInput = ( {
className="components-toolbar__control"
label={
url ?
__( 'Edit link', 'block-options' ) :
__( 'Insert link', 'block-options' )
__( 'Edit link', 'kindling' ) :
__( 'Insert link', 'kindling' )
}
aria-expanded={ isOpen }
onClick={ openLinkUI }
Expand Down Expand Up @@ -173,7 +173,7 @@ const URLInput = ( {
/>
<Button
icon="no"
label={ __( 'Remove link', 'block-options' ) }
label={ __( 'Remove link', 'kindling' ) }
onClick={ onLinkRemove }
/>
</>
Expand Down
5 changes: 3 additions & 2 deletions assets/block-extensions/link-underline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress Dependencies
*/
const { createHigherOrderComponent } = wp.compose;
const { __ } = wp.i18n;

// Create a higher order component to wrap the existing block.
// eslint-disable-next-line no-unused-vars
Expand All @@ -27,9 +28,9 @@ const withInspectorControls = createHigherOrderComponent((BlockEdit) => {
<Fragment>
<BlockEdit {...props} />
<InspectorControls>
<PanelBody title="Additional Settings" initialOpen={true}>
<PanelBody title={__('Additional Settings', 'kindling')} initialOpen={true}>
<ToggleControl
label="Remove links underline"
label={__('Remove links underline', 'kindling')}
checked={removeUnderline}
onChange={(newVal) => {
const newClassName = newVal
Expand Down
3 changes: 2 additions & 1 deletion assets/block-extensions/safe-svg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';
import { ColorPalette, InspectorControls } from '@wordpress/block-editor';
import { PanelBody, TextControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

function addIconColorAttribute(settings, name) {
if (name !== 'safe-svg/svg-icon') { // Replace with the actual block name
Expand Down Expand Up @@ -42,7 +43,7 @@ const addSafeSvgCustomColorInspectorControls = createHigherOrderComponent((Block
<BlockEdit {...props} />
</div>
<InspectorControls>
<PanelBody title={ 'Icon Color' }>
<PanelBody title={__('Icon Color', 'kindling')}>
<ColorPalette
value={ attributes.iconColor }
onChange={ (newColor) => {
Expand Down
16 changes: 8 additions & 8 deletions assets/blocks/search-icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ColorPalette, InspectorControls, BlockControls } from '@wordpress/block
import { PanelBody, Toolbar, ToolbarGroup, ToolbarDropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';

registerBlockType('kindling/custom-search-link', {
title: __( 'Search Link', 'kindling-custom-search-link' ),
title: __( 'Search Link', 'kindling' ),
icon: 'search',
category: 'design',

Expand All @@ -30,22 +30,22 @@ registerBlockType('kindling/custom-search-link', {
const iconSizes = [
{
name: 'small',
title: __('Small', 'kindling-custom-search-link'),
title: __('Small', 'kindling'),
sizeClass: 'has-small-icon-size',
},
{
name: 'medium',
title: __('Medium', 'kindling-custom-search-link'),
title: __('Medium', 'kindling'),
sizeClass: 'has-medium-icon-size',
},
{
name: 'large',
title: __('Large', 'kindling-custom-search-link'),
title: __('Large', 'kindling'),
sizeClass: 'has-large-icon-size',
},
{
name: 'huge',
title: __('Huge', 'kindling-custom-search-link'),
title: __('Huge', 'kindling'),
sizeClass: 'has-huge-icon-size',
},
];
Expand All @@ -55,8 +55,8 @@ registerBlockType('kindling/custom-search-link', {
<BlockControls>
<ToolbarGroup>
<ToolbarDropdownMenu
label={__('Size', 'kindling-custom-search-link')}
text={__('Size', 'kindling-custom-search-link')}
label={__('Size', 'kindling')}
text={__('Size', 'kindling')}
icon={null}
>
{ ({ onClose }) => (
Expand All @@ -83,7 +83,7 @@ registerBlockType('kindling/custom-search-link', {
</ToolbarGroup>
</BlockControls>
<InspectorControls>
<PanelBody title={ __('Icon Color', 'kindling-custom-search-link') }>
<PanelBody title={ __('Icon Color', 'kindling') }>
<ColorPalette
value={ iconColor }
onChange={ (newColor) => setAttributes({ iconColor: newColor }) }
Expand Down
3 changes: 2 additions & 1 deletion assets/blocks/slide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -12,7 +13,7 @@ import Save from './save';

// Export this so we can use it in the edit and save files
export const innerBlocksTemplate = [
[ 'kindling/slide-block', { placeholder: 'Enter slide content...' } ],
[ 'kindling/slide-block', { placeholder: __( 'Enter slide content...', 'kindling' ) } ],
];

// Register the block
Expand Down
13 changes: 7 additions & 6 deletions assets/blocks/slider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { Toolbar, ToolbarButton, Card, CardBody, Button } from '@wordpress/compo
import { chevronLeft, chevronRight, plus } from '@wordpress/icons';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';

/**
* Register a new block type for managing slides
*/
registerBlockType( 'kindling/slider', {
apiVersion: 2,
title: 'Slider',
title: __( 'Slider', 'kindling' ),
category: 'layout',
icon: 'id',

Expand Down Expand Up @@ -78,7 +79,7 @@ registerBlockType( 'kindling/slider', {
// Create a new slide block
const slideBlock = createBlock('kindling/slide', { className: 'editor-inactive-block' }, [
// Create a paragraph block with a placeholder
createBlock('core/paragraph', { placeholder: 'Enter content.' }),
createBlock('core/paragraph', { placeholder: __( 'Enter content.', 'kindling' ) }),
]);

// Replace the inner blocks with the new slide block
Expand Down Expand Up @@ -148,10 +149,10 @@ registerBlockType( 'kindling/slider', {
isPrimary
onClick={addNewSlide}
>
Add Slide
{__( 'Add Slide', 'kindling' )}
</Button>

<p>Editing slide {`${activeBlockIndex + 1} of ${numOfBlocks}`}</p>
<p>{ __( 'Editing slide', 'kindling' ) } {`${activeBlockIndex + 1} of ${numOfBlocks}`}</p>

<div
className='kindling-block-header__button-wrapper'
Expand All @@ -162,15 +163,15 @@ registerBlockType( 'kindling/slider', {
onClick={handlePrev}
variant='secondary'
>
Previous
{ __( 'Previous', 'kindling' ) }
</Button>
<Button
className='kindling-block-header__button next'
icon={chevronRight}
onClick={handleNext}
variant='secondary'
>
Next
{ __( 'Next', 'kindling' ) }
</Button>
</div>

Expand Down
Loading