Not sure i understand what you mean, as this is already the default behaviour of DNN:
* for anonymous users, the preferred language as set in the browser is selected, if available in the portal and if the option hasn't been turned off in Admin > Languages (using the option "")
* for logged on users, the language as set in the user profile is used