| 1 |
/** |
| 2 |
* Mock for @wordpress/i18n package |
| 3 |
* |
| 4 |
* Provides simple pass-through implementations of i18n functions |
| 5 |
* for use in Jest tests. |
| 6 |
*/ |
| 7 |
|
| 8 |
export const __ = ( text: string ): string => text; |
| 9 |
export const _x = ( text: string ): string => text; |
| 10 |
export const _n = ( single: string, plural: string, number: number ): string => |
| 11 |
number === 1 ? single : plural; |
| 12 |
export const _nx = ( |
| 13 |
single: string, |
| 14 |
plural: string, |
| 15 |
number: number |
| 16 |
): string => ( number === 1 ? single : plural ); |
| 17 |
export const sprintf = ( format: string, ...args: unknown[] ): string => { |
| 18 |
let result = format; |
| 19 |
args.forEach( ( arg ) => { |
| 20 |
result = result.replace( /%[sd]/, String( arg ) ); |
| 21 |
} ); |
| 22 |
return result; |
| 23 |
}; |
| 24 |
|