There are different Hebrew words translated as "foreigner" in various English Bibles. They mean different things.

Just something to keep in mind whenever you read an English translation of the Bible. Very few words translate precisely.