Now, I suspect that when the user first signs up, current_user is not set, thus kick-starting the whole get-the-language-from-header process, and then the I18n.locale got persisted into the user’s account.
However, this is certain NOT how it is done when a user redeems an invite.
To allow the locale to be set for anonymous (non-logged in) users based on their browser’s language settings, you need to enable both the allow user locale and set locale from accept language header site settings. Both of those settings are found near the top of your site’s “Basic Setup” settings page.
Once those settings are enabled, users who are not logged into the site will have the Discourse user interface automatically set to the preferred language they have set in their browser. If a non-logged-in user decides to create an account on the site, their locale will be automatically set to the locale that is set by their browser. Note that this will only work if their locale is set to a language that Discourse has been translated into.
The set locale from accept language header setting has no effect on users who have already created accounts on the site. Once an account has been created, the Discourse user interface will be displayed in the locale that is set on the user’s preferences page. As long as the allow user locale setting is enabled, existing users can update their locale here: