Skip to content

Commit

Permalink
Merge pull request #10748 from smellems/getLanguage
Browse files Browse the repository at this point in the history
chore(core): Add getLanguage function to User.
  • Loading branch information
hypeJunction committed Mar 9, 2017
2 parents 3eb5a84 + f0aab0a commit 7cc37ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions engine/classes/ElggUser.php
Expand Up @@ -156,6 +156,24 @@ protected function update() {
return $this->getDatabase()->updateData($query) !== false;
}

/**
* Get user language or default to site language
*
* @param string $fallback If this is provided, it will be returned if the user doesn't have a language set.
* If null, the site language will be returned.
*
* @return string
*/
public function getLanguage($fallback = null) {
if (!empty($this->language)) {
return $this->language;
}
if ($fallback !== null) {
return $fallback;
}
return elgg_get_config('language');
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 7cc37ce

Please sign in to comment.