Skip to content

Commit

Permalink
Internationalize block source #47
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbingwide committed Aug 31, 2021
1 parent 846927a commit b810495
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
5 changes: 3 additions & 2 deletions src/oik-blockicon/blockicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* I supposed it's just a syntax thing.. modern JavaScript ES2015 vs original.
* So here we have a mixture.
*
* @copyright (C) Copyright Bobbing Wide 2019,2020
* @copyright (C) Copyright Bobbing Wide 2019,2020,2021
* @author Herb Miller @bobbingwide
*
*/
import { __ } from '@wordpress/i18n';

const { Component } = wp.element;
const{ getBlockTypes, getBlockType, hasBlockSupport, getBlockVariations } = wp.blocks;
Expand All @@ -26,7 +27,7 @@ function BlockiconsSelect( { value, onChange, ...props } ) {
return (


<SelectControl label="Blocks" value={ value } options={ options } onChange={ onChange } />
<SelectControl label={ __("Blocks", 'oik-blocks' )} value={ value } options={ options } onChange={ onChange } />
);
//this.renderBlockiconList();

Expand Down
16 changes: 8 additions & 8 deletions src/oik-blockinfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,31 +155,31 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block link' ) }
label={ __( 'Show block link', 'oik-blocks' ) }
checked={ !! props.attributes.showBlockLink }
onChange={ onChangeShowBlockLink }

/>
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block icon' ) }
label={ __( 'Show block icon', 'oik-blocks' ) }
checked={ !! props.attributes.showBlockIcon }
onChange={ onChangeShowBlockIcon }

/>
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block type name' ) }
label={ __( 'Show block type name', 'oik-blocks' ) }
checked={ !! props.attributes.showBlockTypeName }
onChange={ onChangeShowBlockTypeName }

/>
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block title' ) }
label={ __( 'Show block title', 'oik-blocks' ) }
checked={ !! props.attributes.showTitle }
onChange={ onChangeShowTitle }

Expand All @@ -188,7 +188,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block description' ) }
label={ __( 'Show block description', 'oik-blocks' ) }
checked={ !! props.attributes.showDescription }
onChange={ onChangeShowDescription }

Expand All @@ -197,7 +197,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show category' ) }
label={ __( 'Show category', 'oik-blocks' ) }
checked={ !! props.attributes.showCategory }
onChange={ onChangeShowCategory }

Expand All @@ -206,7 +206,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show keywords' ) }
label={ __( 'Show keywords', 'oik-blocks' ) }
checked={ !! props.attributes.showKeywords }
onChange={ onChangeShowKeywords }

Expand All @@ -215,7 +215,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show variations' ) }
label={ __( 'Show variations', 'oik-blocks' ) }
checked={ !! props.attributes.showVariations }
onChange={ onChangeShowVariations }

Expand Down
8 changes: 3 additions & 5 deletions src/oik-blocklist/blockprefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
* The onChange function will have to do that.
*
*
* @copyright (C) Copyright Bobbing Wide 2019
* @copyright (C) Copyright Bobbing Wide 2019,2021
* @author Herb Miller @bobbingwide
*
*/
import { __ } from '@wordpress/i18n';

const { Component } = wp.element;
const{ getBlockTypes, getBlockType } = wp.blocks;
Expand All @@ -26,7 +27,7 @@ function BlockPrefixSelect( { value, onChange, ...props } ) {
return (


<SelectControl label="Prefix" value={ value } options={ options } onChange={ onChange } />
<SelectControl label={ __("Prefix", 'oik-blocks' )} value={ value } options={ options } onChange={ onChange } />
);
//this.renderBlockiconList();

Expand Down Expand Up @@ -92,7 +93,4 @@ function getOptionLabel( block ) {
return label;
}




export { BlockPrefixSelect, getNameSpace };
10 changes: 5 additions & 5 deletions src/oik-blocklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show block link' ) }
label={ __( 'Show block link', 'oik-blocks' ) }
checked={ !! props.attributes.showBlockLink }
onChange={ onChangeShowBlockLink }

Expand All @@ -113,7 +113,7 @@ export default registerBlockType(

<PanelRow>
<ToggleControl
label={ __( 'Show block description' ) }
label={ __( 'Show block description', 'oik-blocks' ) }
checked={ !! props.attributes.showDescription }
onChange={ onChangeShowDescription }

Expand All @@ -122,7 +122,7 @@ export default registerBlockType(
</PanelRow>
<PanelRow>
<ToggleControl
label={ __( 'Show batch commands' ) }
label={ __( 'Show batch commands', 'oik-blocks' ) }
checked={ !! props.attributes.showBatch }
onChange={ onChangeShowBatch }

Expand All @@ -131,7 +131,7 @@ export default registerBlockType(
</PanelRow>

<PanelRow>
<TextControl label={"Component"} value={ props.attributes.component} onChange={ onChangeComponent }/>
<TextControl label={__( "Component", 'oik-blocks' )} value={ props.attributes.component} onChange={ onChangeComponent }/>
</PanelRow>


Expand Down Expand Up @@ -166,4 +166,4 @@ export default registerBlockType(
);
},
},
);
);
34 changes: 12 additions & 22 deletions src/oik-fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ import {AlignmentControl, BlockControls, InspectorControls, useBlockProps, Plain
* These are the different options for "virtual" fields
*/
const fieldsOptions =
{ "none": "All",
"featured": "Featured image",
"file_size": "File size of attachment",
"dimensions": "Image dimensions",
"thumbnail": "Thumbnail",
"googlemap": "Google Maps Map",
"template": "Page template name",
"post_date": "Post date",
"post_modified": "Post modified date",
//"author": "Author",
"author_name": "Author name"
{ "none": __("All", 'oik-blocks' ),
"featured": __("Featured image", 'oik-blocks' ),
"file_size": __("File size of attachment", 'oik-blocks' ),
"dimensions": __("Image dimensions", 'oik-blocks' ),
"thumbnail": __("Thumbnail", 'oik-blocks' ),
"googlemap": __("Google Maps Map", 'oik-blocks' ),
"template": __("Page template name", 'oik-blocks' ),
"post_date": __("Post date", 'oik-blocks' ),
"post_modified": __("Post modified date", 'oik-blocks' ),
//"author": __("Author", 'oik-blocks' ),
"author_name": __("Author name", 'oik-blocks' )
};


Expand Down Expand Up @@ -91,27 +91,19 @@ export default registerBlockType(
props.setAttributes( { [key] : value } );
};



return (
<Fragment>
<InspectorControls >
<PanelBody>
<PanelRow>
<SelectControl label="Fields" value={props.attributes.fields}
<SelectControl label={__("Fields", 'oik-blocks')} value={props.attributes.fields}
options={ map( fieldsOptions, ( key, label ) => ( { value: label, label: key } ) ) }
onChange={partial( onChangeAttr, 'fields' )}
/>

</PanelRow>

<PanelRow>


</PanelRow>
<PanelRow>

</PanelRow>
</PanelBody>

</InspectorControls>
Expand All @@ -121,11 +113,9 @@ export default registerBlockType(
/>
</div>
</Fragment>

);
},


save() {
return null;
},
Expand Down

0 comments on commit b810495

Please sign in to comment.