The answer is already given at the first 2 replies. Follow that but don't forget to add an escaping function there as well.
this is how you translate texts with one value or function:
sprintf(
esc_html__( 'Your translatable text goes here and value is %s.', 'textdomain' ),
$value_or_function
);
And in the following way, you can add multiple values/ functions to yout translatable texts.
sprintf(
esc_html__( 'this is how you can add multiple values. value1: %1$s, and value2: %2$s.', 'textdomain' ),
$value_or_function1,
$value_or_function2
);
Here is a brief about this sprintf function:
The arg1, arg2, ++ parameters will be inserted at percent (%) signs in the main string. This function works "step-by-step". At the first % sign, arg1 is inserted, at the second % sign, arg2 is inserted, etc.
Syntax: sprintf(format,arg1,arg2,arg++)
Possible format values:
%% - Returns a percent sign
%b - Binary number
%c - The character according to the ASCII value
%d - Signed decimal number (negative, zero or positive)
%e - Scientific notation using a lowercase (e.g. 1.2e+2)
%E - Scientific notation using a uppercase (e.g. 1.2E+2)
%u - Unsigned decimal number (equal to or greater than zero)
%f - Floating-point number (local settings aware)
%F - Floating-point number (not local settings aware)
%g - shorter of %e and %f
%G - shorter of %E and %f
%o - Octal number
%s - String
%x - Hexadecimal number (lowercase letters)
%X - Hexadecimal number (uppercase letters)
But generally we use %s and assume that the argument value will be a string.