The code you're linking to is for the edit form, not the register form. It's used to set the default value of the locale selector for users that are already registered, and with no locale set.