I am sorry for so many prs <3 (#389)

* make language loading more solid

* disable browser lang preferences

* pr fix

* pr fixes

* pr fixes

* make sure language files are named correctly

* fix dropdown width issue when in modal form

* fix issue from jquery hell
This commit is contained in:
Andrew Camilleri 2018-11-09 13:13:00 +01:00 committed by Nicolas Dorier
parent 2ec2c7263f
commit daf4e5ce6c
19 changed files with 30 additions and 23 deletions

View File

@ -87,21 +87,23 @@
onchange="changeLanguage($(this).val())"
asp-items="@langService.GetLanguages().Select((language) => new SelectListItem(language.DisplayName,language.Code, false))"></select>
<script>
$(function() {
// REVIEW: don't use initDropdown method but rather directly initialize select whenever you are using it
initDropdown(".cmblang");
});
function initDropdown(selector) {
return $(selector).prettyDropdown({
classic: false,
height: 32,
reverse: true,
hoverIntent: 5000
<script>
var languageSelectorPrettyDropdown;
$(function() {
// REVIEW: don't use initDropdown method but rather directly initialize select whenever you are using it
$("#DefaultLang").val(startingLanguage);
languageSelectorPrettyDropdown = initDropdown("#DefaultLang");
});
}
</script>
function initDropdown(selector) {
return $(selector).prettyDropdown({
classic: false,
height: 32,
reverse: true,
hoverIntent: 5000
});
}
</script>
</div>
<div style="margin-top: 10px; text-align: center;" class="form-text small text-muted">
<span>Powered by <a target="_blank" href="https://github.com/btcpayserver/btcpayserver">BTCPay Server</a></span>
@ -117,11 +119,8 @@
.Select((language) => language.Code)));;
var storeDefaultLang = "@Model.DefaultLang";
var fallbackLanguage = "en";
var languageDropdownElement = $("#DefaultLang");
var startingLanguage = computeStartingLanguage();
// initialization
startingLanguage = computeStartingLanguage();
// initialization
i18next
.use(window.i18nextXHRBackend)
.init({
@ -146,9 +145,9 @@
}
function changeLanguage(lang) {
if (isLanguageAvailable(lang)) {
i18next.changeLanguage(lang);
}
if (isLanguageAvailable(lang)) {
i18next.changeLanguage(lang);
}
}
function isLanguageAvailable(languageCode) {

View File

@ -11495,4 +11495,12 @@ low-fee-timeline {
}
#prettydropdown-DefaultLang{
min-width:200px;
}
#prettydropdown-DefaultLang ul{
width:100%;
}
#prettydropdown-DefaultLang ul li{
width:100% !important;
}