I've defined one db authentication in my Moodle server. One of the fields I've defined to be syncronished is the user lang.
All my test users (in external DB) have es_utf8 defined but, when I log into Moodle, such lang is ignored and they get en_utf8 (the default site lang).
The responsible line seems to be create_user_record() in moodlelib.php. There is one line that says:
$newuser->lang = $CFG->lang;
just before inserting the new user record. I would:
1) Only apply $CFG->lang if $newuser->lang is empty.
2) Check, before insert, that the $newuser->lang information is a valid and installed lang. If not, default to $CFG->lang
P.S.: I haven't reviewed if this also happens in HEAD but I've marked it as target too!