Converting db_query from Drupal 6 to Drupal 7: Invalid parameter number: number of bound variables does not match number of tokens
You've quoted one of the parameters when you shouldn't have.

PDO interprets this:

':source_swe'


as a string, and it (correctly) doesn't try to change it.

What you're looking for is simply

:source_swe


So that parameter replacement can occur. As in,

db_query("REPLACE INTO {locales_target} (lid, translation, language) VALUES ((SELECT lid FROM {locales_source} WHERE source = :source_eng LIMIT 1), :source_swe, 'sv')", array(':source_eng' =&gt; $name['eng'], ':source_swe' =&gt; $name['swe']));