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

1171: Ensure translatable strings in blocks can actually be translated #1173

Merged
merged 5 commits into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
{
"pragma": "wp.element.createElement"
}
],
[
"@wordpress/babel-plugin-makepot",
{
"output": "languages/amp-js.pot"
}
]
],
"env": {
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ node_modules
wiki
amp.zip
**/*-compiled.js
languages/*.pot
languages/*.php
28 changes: 14 additions & 14 deletions assets/js/amp-editor-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
ampLayoutOptions: [
{
value: 'nodisplay',
label: __( 'No Display' ),
label: __( 'No Display', 'amp' ),
notAvailable: [
'core-embed/vimeo',
'core-embed/dailymotion',
Expand All @@ -27,36 +27,36 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
{
// Not supported by amp-audio and amp-pixel.
value: 'fixed',
label: __( 'Fixed' ),
label: __( 'Fixed', 'amp' ),
notAvailable: [
'core-embed/soundcloud'
]
},
{
// To ensure your AMP element displays, you must specify a width and height for the containing element.
value: 'responsive',
label: __( 'Responsive' ),
label: __( 'Responsive', 'amp' ),
notAvailable: [
'core/audio',
'core-embed/soundcloud'
]
},
{
value: 'fixed-height',
label: __( 'Fixed height' ),
label: __( 'Fixed height', 'amp' ),
notAvailable: []
},
{
value: 'fill',
label: __( 'Fill' ),
label: __( 'Fill', 'amp' ),
notAvailable: [
'core/audio',
'core-embed/soundcloud'
]
},
{
value: 'flex-item',
label: __( 'Flex Item' ),
label: __( 'Flex Item', 'amp' ),
notAvailable: [
'core/audio',
'core-embed/soundcloud'
Expand All @@ -65,7 +65,7 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
{
// Not supported by video.
value: 'intrinsic',
label: __( 'Intrinsic' ),
label: __( 'Intrinsic', 'amp' ),
notAvailable: [
'core/audio',
'core-embed/youtube',
Expand Down Expand Up @@ -120,7 +120,7 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
var layoutOptions = [
{
value: '',
label: __( 'Default' )
label: __( 'Default', 'amp' )
}
];

Expand Down Expand Up @@ -282,15 +282,15 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
SelectControl = wp.components.SelectControl,
ToggleControl = wp.components.ToggleControl,
PanelBody = wp.components.PanelBody,
label = __( 'AMP Layout' );
label = __( 'AMP Layout', 'amp' );

if ( 'core/image' === name ) {
label = __( 'AMP Layout (modifies width/height)' );
label = __( 'AMP Layout (modifies width/height)', 'amp' );
}

return isSelected && (
el( InspectorControls, { key: 'inspector' },
el( PanelBody, { title: __( 'AMP Settings' ) },
el( PanelBody, { title: __( 'AMP Settings', 'amp' ) },
el( SelectControl, {
label: label,
value: ampLayout,
Expand All @@ -303,7 +303,7 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars
}
} ),
el( ToggleControl, {
label: __( 'AMP loading indicator disabled' ),
label: __( 'AMP loading indicator disabled', 'amp' ),
checked: ampNoLoading,
onChange: function() {
props.setAttributes( { ampNoLoading: ! ampNoLoading } );
Expand Down Expand Up @@ -332,15 +332,15 @@ var ampEditorBlocks = ( function() { // eslint-disable-line no-unused-vars

if ( component.isGalleryShortcode( props.attributes ) ) {
toggleControl = el( ToggleControl, {
label: __( 'Display as AMP carousel' ),
label: __( 'Display as AMP carousel', 'amp' ),
checked: ampCarousel,
onChange: function() {
props.setAttributes( { ampCarousel: ! ampCarousel } );
}
} );
return isSelected && (
el( InspectorControls, { key: 'inspector' },
el( PanelBody, { title: __( 'AMP Settings' ) },
el( PanelBody, { title: __( 'AMP Settings', 'amp' ) },
toggleControl
)
)
Expand Down
46 changes: 23 additions & 23 deletions blocks/amp-brid-player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const {
export default registerBlockType(
'amp/amp-brid-player',
{
title: __( 'AMP Brid Player' ),
description: __( 'Displays the Brid Player used in Brid.tv Video Platform.' ),
title: __( 'AMP Brid Player', 'amp' ),
description: __( 'Displays the Brid Player used in Brid.tv Video Platform.', 'amp' ),
category: 'common',
icon: 'embed-generic',
keywords: [
__( 'Embed' )
__( 'Embed', 'amp' )
],

attributes: {
Expand Down Expand Up @@ -63,12 +63,12 @@ export default registerBlockType(
edit( { attributes, isSelected, setAttributes } ) {
const { autoPlay, dataPartner, dataPlayer, dataVideo, dataPlaylist, dataOutstream, layout, height, width } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive' ) },
{ value: 'fixed-height', label: __( 'Fixed height' ) },
{ value: 'fixed', label: __( 'Fixed' ) },
{ value: 'fill', label: __( 'Fill' ) },
{ value: 'flex-item', label: __( 'Flex-item' ) },
{ value: 'nodisplay', label: __( 'No Display' ) }
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
{ value: 'fixed-height', label: __( 'Fixed height', 'amp' ) },
{ value: 'fixed', label: __( 'Fixed', 'amp' ) },
{ value: 'fill', label: __( 'Fill', 'amp' ) },
{ value: 'flex-item', label: __( 'Flex-item', 'amp' ) },
{ value: 'nodisplay', label: __( 'No Display', 'amp' ) }

];
let url = false;
Expand All @@ -80,52 +80,52 @@ export default registerBlockType(
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'Brid Player Settings' ) }>
<PanelBody title={ __( 'Brid Player Settings', 'amp' ) }>
<TextControl
label={ __( 'Brid.tv partner ID (required)' ) }
label={ __( 'Brid.tv partner ID (required)', 'amp' ) }
value={ dataPartner }
onChange={ value => ( setAttributes( { dataPartner: value } ) ) }
/>
<TextControl
label={ __( 'Brid.tv player ID (required)' ) }
label={ __( 'Brid.tv player ID (required)', 'amp' ) }
value={ dataPlayer }
onChange={ value => ( setAttributes( { dataPlayer: value } ) ) }
/>
<TextControl
label={ __( 'Video ID (one of video / playlist / outstream ID is required)' ) }
label={ __( 'Video ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataVideo }
onChange={ value => ( setAttributes( { dataVideo: value } ) ) }
/>
<TextControl
label={ __( 'Outstream unit ID (one of video / playlist / outstream ID is required)' ) }
label={ __( 'Outstream unit ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataOutstream }
onChange={ value => ( setAttributes( { dataOutstream: value } ) ) }
/>
<TextControl
label={ __( 'Playlist ID (one of video / playlist / outstream ID is required)' ) }
label={ __( 'Playlist ID (one of video / playlist / outstream ID is required)', 'amp' ) }
value={ dataPlaylist }
onChange={ value => ( setAttributes( { dataPlaylist: value } ) ) }
/>
<ToggleControl
label={ __( 'Autoplay' ) }
label={ __( 'Autoplay', 'amp' ) }
checked={ autoPlay }
onChange={ () => ( setAttributes( { autoPlay: ! autoPlay } ) ) }
/>
<SelectControl
label={ __( 'Layout' ) }
label={ __( 'Layout', 'amp', 'amp' ) }
value={ layout }
options={ ampLayoutOptions }
onChange={ value => ( setAttributes( { layout: value } ) ) }
/>
<TextControl
type="number"
label={ __( 'Width (px)' ) }
label={ __( 'Width (px)', 'amp' ) }
value={ width !== undefined ? width : '' }
onChange={ value => ( setAttributes( { width: value } ) ) }
/>
<TextControl
type="number"
label={ __( 'Height (px)' ) }
label={ __( 'Height (px)', 'amp' ) }
value={ height }
onChange={ value => ( setAttributes( { height: value } ) ) }
/>
Expand All @@ -135,17 +135,17 @@ export default registerBlockType(
}
{
url && (
<Placeholder label={ __( 'Brid Player' ) }>
<Placeholder label={ __( 'Brid Player', 'amp' ) }>
<p className="components-placeholder__error">{ url }</p>
<p className="components-placeholder__error">{ __( 'Previews for this are unavailable in the editor, sorry!' ) }</p>
<p className="components-placeholder__error">{ __( 'Previews for this are unavailable in the editor, sorry!', 'amp' ) }</p>
</Placeholder>
)

}
{
! url && (
<Placeholder label={ __( 'Brid Player' ) }>
<p>{ __( 'Add required data to use the block.' ) }</p>
<Placeholder label={ __( 'Brid Player', 'amp' ) }>
<p>{ __( 'Add required data to use the block.', 'amp' ) }</p>
</Placeholder>
)
}
Expand Down
34 changes: 17 additions & 17 deletions blocks/amp-ima-video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const {
export default registerBlockType(
'amp/amp-ima-video',
{
title: __( 'AMP IMA Video' ),
description: __( 'Embeds a video player for instream video ads that are integrated with the IMA SDK' ),
title: __( 'AMP IMA Video', 'amp' ),
description: __( 'Embeds a video player for instream video ads that are integrated with the IMA SDK', 'amp' ),
category: 'common',
icon: 'embed-generic',
keywords: [
__( 'Embed' )
__( 'Embed', 'amp' )
],

// @todo Perhaps later add subtitles option and additional source options?
Expand Down Expand Up @@ -58,8 +58,8 @@ export default registerBlockType(
edit( { attributes, isSelected, setAttributes } ) {
const { dataDelayAdRequest, dataTag, dataSrc, dataPoster, layout, height, width } = attributes;
const ampLayoutOptions = [
{ value: 'responsive', label: __( 'Responsive' ) },
{ value: 'fixed', label: __( 'Fixed' ) }
{ value: 'responsive', label: __( 'Responsive', 'amp' ) },
{ value: 'fixed', label: __( 'Fixed', 'amp' ) }

];
let dataSet = false;
Expand All @@ -71,42 +71,42 @@ export default registerBlockType(
{
isSelected && (
<InspectorControls key='inspector'>
<PanelBody title={ __( 'IMA Video Settings' ) }>
<PanelBody title={ __( 'IMA Video Settings', 'amp' ) }>
<TextControl
label={ __( 'Https URL for your VAST ad document (required)' ) }
label={ __( 'Https URL for your VAST ad document (required)', 'amp' ) }
value={ dataTag }
onChange={ value => ( setAttributes( { dataTag: value } ) ) }
/>
<TextControl
label={ __( 'Https URL of your video content (required)' ) }
label={ __( 'Https URL of your video content (required)', 'amp' ) }
value={ dataSrc }
onChange={ value => ( setAttributes( { dataSrc: value } ) ) }
/>
<TextControl
label={ __( 'Https URL to preview image' ) }
label={ __( 'Https URL to preview image', 'amp' ) }
value={ dataPoster }
onChange={ value => ( setAttributes( { dataPoster: value } ) ) }
/>
<ToggleControl
label={ __( 'Delay Ad Request' ) }
label={ __( 'Delay Ad Request', 'amp' ) }
checked={ dataDelayAdRequest }
onChange={ () => ( setAttributes( { dataDelayAdRequest: ! dataDelayAdRequest } ) ) }
/>
<SelectControl
label={ __( 'Layout' ) }
label={ __( 'Layout', 'amp' ) }
value={ layout }
options={ ampLayoutOptions }
onChange={ value => ( setAttributes( { layout: value } ) ) }
/>
<TextControl
type="number"
label={ __( 'Width (px)' ) }
label={ __( 'Width (px)', 'amp' ) }
value={ width !== undefined ? width : '' }
onChange={ value => ( setAttributes( { width: value } ) ) }
/>
<TextControl
type="number"
label={ __( 'Height (px)' ) }
label={ __( 'Height (px)', 'amp' ) }
value={ height }
onChange={ value => ( setAttributes( { height: value } ) ) }
/>
Expand All @@ -116,16 +116,16 @@ export default registerBlockType(
}
{
dataSet && (
<Placeholder label={ __( 'IMA Video' ) }>
<Placeholder label={ __( 'IMA Video', 'amp' ) }>
<p className="components-placeholder__error">{ dataSrc }</p>
<p className="components-placeholder__error">{ __( 'Previews for this are unavailable in the editor, sorry!' ) }</p>
<p className="components-placeholder__error">{ __( 'Previews for this are unavailable in the editor, sorry!', 'amp' ) }</p>
</Placeholder>
)
}
{
! dataSet && (
<Placeholder label={ __( 'IMA Video' ) }>
<p>{ __( 'Add required data to use the block.' ) }</p>
<Placeholder label={ __( 'IMA Video', 'amp' ) }>
<p>{ __( 'Add required data to use the block.', 'amp' ) }</p>
</Placeholder>
)
}
Expand Down
Loading