Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
import { Locator } from 'playwright';
/**
* Translate string by evaluating the `wp.i18n__` translate function from the page.
*/
export async function translateFromPage(
locator: Locator,
string: string,
context?: string
): Promise< string > {
return (
locator.evaluate(
// eslint-disable-next-line @wordpress/i18n-no-variables
( _el, [ string, context ] ) =>
context === undefined
? // eslint-disable-next-line @wordpress/i18n-no-variables
( window as any )?.wp?.i18n?.__( string )
: // eslint-disable-next-line @wordpress/i18n-no-variables
( window as any )?.wp?.i18n?._x( string, context ),
[ string, context ]
) || Promise.resolve( string )
);
}