a little change on the mechanism which handles automatically language detection

I think this change will make the detection faster, because there is no necessary to replace '-' every time, and the next step to handle the second part of $lang can do it at the same time.