mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
provide locale samples
This commit is contained in:
parent
a7df12c88b
commit
da8cde234a
@ -550,6 +550,19 @@ namespace CarCareTracker.Controllers
|
||||
return Json(false);
|
||||
}
|
||||
[Authorize(Roles = nameof(UserData.IsRootUser))]
|
||||
public IActionResult GetLocaleSample(string locale)
|
||||
{
|
||||
var cultureInfo = CultureInfo.GetCultureInfo(locale);
|
||||
var viewModel = new LocaleSample
|
||||
{
|
||||
ShortDateSample = DateTime.Now.ToString(cultureInfo.DateTimeFormat.ShortDatePattern),
|
||||
CurrencySample = 13.45M.ToString("C", cultureInfo),
|
||||
NumberSample = 123456.ToString("N", cultureInfo),
|
||||
DecimalSample = 123456.78M.ToString("N2", cultureInfo)
|
||||
};
|
||||
return PartialView("_LocaleSample", viewModel);
|
||||
}
|
||||
[Authorize(Roles = nameof(UserData.IsRootUser))]
|
||||
[Route("/setup")]
|
||||
public IActionResult Setup()
|
||||
{
|
||||
|
||||
10
Models/Settings/LocaleSample.cs
Normal file
10
Models/Settings/LocaleSample.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace CarCareTracker.Models
|
||||
{
|
||||
public class LocaleSample
|
||||
{
|
||||
public string ShortDateSample { get; set; }
|
||||
public string CurrencySample { get; set; }
|
||||
public string NumberSample { get; set; }
|
||||
public string DecimalSample { get; set; }
|
||||
}
|
||||
}
|
||||
@ -57,13 +57,14 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputLocale">@translator.Translate(userLanguage, "Locale Override")</label>
|
||||
<select class="form-select" id="inputLocale">
|
||||
<select class="form-select" id="inputLocale" onchange="loadLocaleSample()">
|
||||
@foreach(string installedLocale in Model.AvailableLocales)
|
||||
{
|
||||
<!option value="@installedLocale" @(Model.LocaleOverride == installedLocale ? "selected" : "")>@installedLocale</!option>
|
||||
}
|
||||
</select>
|
||||
<small class="text-body-secondary">@translator.Translate(userLanguage, "Leave blank to use system locale. Restart Required")</small>
|
||||
<div id="localeSampleContainer" style="display:none;"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputFileExt">@translator.Translate(userLanguage, "Allowed File Extensions")</label>
|
||||
|
||||
14
Views/Home/_LocaleSample.cshtml
Normal file
14
Views/Home/_LocaleSample.cshtml
Normal file
@ -0,0 +1,14 @@
|
||||
@using CarCareTracker.Helper
|
||||
@inject IConfigHelper config
|
||||
@inject ITranslationHelper translator
|
||||
@model LocaleSample
|
||||
@{
|
||||
var userConfig = config.GetUserConfig(User);
|
||||
var userLanguage = userConfig.UserLanguage;
|
||||
}
|
||||
<div class="d-flex flex-column text-secondary">
|
||||
<span>@translator.Translate(userLanguage, "Short Date"): @Model.ShortDateSample</span>
|
||||
<span>@translator.Translate(userLanguage, "Currency"): @Model.CurrencySample</span>
|
||||
<span>@translator.Translate(userLanguage, "Number"): @Model.NumberSample</span>
|
||||
<span>@translator.Translate(userLanguage, "Decimal"): @Model.DecimalSample</span>
|
||||
</div>
|
||||
File diff suppressed because one or more lines are too long
@ -39,6 +39,17 @@ function previousSetupPage() {
|
||||
let prevPage = parseInt(currentVisiblePage) - 1;
|
||||
loadSetupPage(prevPage);
|
||||
}
|
||||
function loadLocaleSample() {
|
||||
let selectedLocale = $("#inputLocale").val();
|
||||
if (selectedLocale.trim() == '') {
|
||||
$("#localeSampleContainer").hide();
|
||||
} else {
|
||||
$.get(`/Home/GetLocaleSample?locale=${selectedLocale}`, function (data) {
|
||||
$("#localeSampleContainer").html(data);
|
||||
$("#localeSampleContainer").show();
|
||||
})
|
||||
}
|
||||
}
|
||||
function saveSetup() {
|
||||
let setupData = {
|
||||
LocaleOverride: $("#inputLocale").val(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user