feat: set the user's locale while creating an account
Previously, every user's locale was defaulted as `en_GB`. Now the browser's locale is used, if it is available.
This commit is contained in:
parent
2fc6d42897
commit
4f07265921
2 changed files with 23 additions and 4 deletions
|
@ -118,6 +118,12 @@ $page->navigation();
|
||||||
?>
|
?>
|
||||||
<a href="https://github.com/grandeljay/wishthis/issues/70" target="_blank">#70</a>
|
<a href="https://github.com/grandeljay/wishthis/issues/70" target="_blank">#70</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<?php
|
||||||
|
/** TRANSLATORS: Changelog: Added */
|
||||||
|
echo __('After creating an account your language is automatically set to your browser\'s (if it is available), instead of defaulting to en_GB.');
|
||||||
|
?>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3 class="ui header"><?= __('Fixed') ?></h3>
|
<h3 class="ui header"><?= __('Fixed') ?></h3>
|
||||||
|
|
|
@ -108,6 +108,13 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
$page->messages[] = Page::error(__('This password reset link seems to have been manipulated, please request a new one.'), __('Failure'));
|
$page->messages[] = Page::error(__('This password reset link seems to have been manipulated, please request a new one.'), __('Failure'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$locale_browser = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']) : DEFAULT_LOCALE;
|
||||||
|
$locale_user = DEFAULT_LOCALE;
|
||||||
|
|
||||||
|
if (in_array($locale_browser, $locales, true)) {
|
||||||
|
$locale_user = $locale_browser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register
|
* Register
|
||||||
*/
|
*/
|
||||||
|
@ -116,15 +123,18 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
'INSERT INTO `users` (
|
'INSERT INTO `users` (
|
||||||
`email`,
|
`email`,
|
||||||
`password`,
|
`password`,
|
||||||
`power`
|
`power`,
|
||||||
|
`language`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
:user_email,
|
:user_email,
|
||||||
:user_password,
|
:user_password,
|
||||||
100
|
100,
|
||||||
|
:user_language
|
||||||
);',
|
);',
|
||||||
array(
|
array(
|
||||||
'user_email' => $user_email,
|
'user_email' => $user_email,
|
||||||
'user_password' => User::generatePassword($_POST['password']),
|
'user_password' => User::generatePassword($_POST['password']),
|
||||||
|
'user_language' => $locale_user,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$userRegistered = true;
|
$userRegistered = true;
|
||||||
|
@ -138,14 +148,17 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
$database->query(
|
$database->query(
|
||||||
'INSERT INTO `users` (
|
'INSERT INTO `users` (
|
||||||
`email`,
|
`email`,
|
||||||
`password`
|
`password`,
|
||||||
|
`language`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
:user_email,
|
:user_email,
|
||||||
:user_password
|
:user_password,
|
||||||
|
:user_language
|
||||||
);',
|
);',
|
||||||
array(
|
array(
|
||||||
'user_email' => $user_email,
|
'user_email' => $user_email,
|
||||||
'user_password' => User::generatePassword($_POST['password']),
|
'user_password' => User::generatePassword($_POST['password']),
|
||||||
|
'user_language' => $locale_user,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$userRegistered = true;
|
$userRegistered = true;
|
||||||
|
|
Loading…
Reference in a new issue