Fix bug in translator replacements for strings that have the same beginning. Fixes #1114.