/** * WordPress dependencies */ import { createInterpolateElement } from '@safe-wordpress/element'; import { sprintf, _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { ConversionActionScopeView } from '@nab/components'; import type { CAViewProps, ConversionActionScope } from '@nab/types'; /** * Internal dependencies */ import type { Attributes } from './types'; export const View = ( props: CAViewProps< Attributes > ): JSX.Element => ( <>
${ videoId }`
)
: sprintf(
getKnownVideoEndLabel( scope ),
`${ videoId }`
),
{ code: }
);
};
// =======
// HELPERS
// =======
function getUnknownVideoPlayLabel( scope: ConversionActionScope ): string {
switch ( scope.type ) {
case 'all-pages':
return _x(
'A visitor plays a specific YouTube video on any page.',
'text',
'nelio-ab-testing'
);
case 'test-scope':
return _x(
'A visitor plays a specific YouTube video on a tested page.',
'text',
'nelio-ab-testing'
);
case 'urls':
case 'post-ids':
case 'php-function':
return _x(
'A visitor plays a specific YouTube video on certain pages.',
'text',
'nelio-ab-testing'
);
}
}
function getUnknownVideoEndLabel( scope: ConversionActionScope ): string {
switch ( scope.type ) {
case 'all-pages':
return _x(
'A visitor reaches the end of a YouTube video on any page.',
'text',
'nelio-ab-testing'
);
case 'test-scope':
return _x(
'A visitor reaches the end of a YouTube video on a tested page.',
'text',
'nelio-ab-testing'
);
case 'urls':
case 'post-ids':
case 'php-function':
return _x(
'A visitor reaches the end of a YouTube video on certain pages.',
'text',
'nelio-ab-testing'
);
}
}
function getKnownVideoPlayLabel( scope: ConversionActionScope ): string {
switch ( scope.type ) {
case 'all-pages':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor plays the YouTube video %s on any page.',
'text',
'nelio-ab-testing'
);
case 'test-scope':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor plays the YouTube video %s on a tested page.',
'text',
'nelio-ab-testing'
);
case 'urls':
case 'post-ids':
case 'php-function':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor plays the YouTube video %s on certain pages.',
'text',
'nelio-ab-testing'
);
}
}
function getKnownVideoEndLabel( scope: ConversionActionScope ): string {
switch ( scope.type ) {
case 'all-pages':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor reaches the end of the YouTube video %s on any page.',
'text',
'nelio-ab-testing'
);
case 'test-scope':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor reaches the end of the YouTube video %s on a tested page.',
'text',
'nelio-ab-testing'
);
case 'urls':
case 'post-ids':
case 'php-function':
/* translators: %s: Video id, such as “dQw4w9WgXcQ”. */
return _x(
'A visitor reaches the end of the YouTube video %s on certain pages.',
'text',
'nelio-ab-testing'
);
}
}