Fixing the bug when casting string to locale