Localization fix

The original version was not working and had faulty logic. Variables were declared but not used and localization wasn't used properly. This should fix that.