API New JS sprintf and inject replacement functions

Fix sprintf issues when replacement was at start of string + introduce
new inject function using injection map similar to the PHP version of
_t()