WIP
This commit is contained in:
parent
54b057886c
commit
7fc1ae0650
204 changed files with 4345 additions and 134 deletions
|
|
@ -0,0 +1,8 @@
|
|||
namespace PlanTempus.Application.Features.Localization.Models;
|
||||
|
||||
public class SupportedCulture
|
||||
{
|
||||
public required string Code { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string NativeName { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using PlanTempus.Application.Features.Localization.Models;
|
||||
|
||||
namespace PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
public interface ILocalizationService
|
||||
{
|
||||
string Get(string key, string? culture = null);
|
||||
string CurrentCulture { get; }
|
||||
IEnumerable<SupportedCulture> GetSupportedCultures();
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using System.Text.Json;
|
||||
using PlanTempus.Application.Features.Localization.Models;
|
||||
|
||||
namespace PlanTempus.Application.Features.Localization.Services;
|
||||
|
||||
public class JsonLocalizationService : ILocalizationService
|
||||
{
|
||||
private readonly string _translationsPath;
|
||||
|
||||
public JsonLocalizationService(IWebHostEnvironment env)
|
||||
{
|
||||
_translationsPath = Path.Combine(env.ContentRootPath, "Features", "Localization", "Translations");
|
||||
}
|
||||
|
||||
public string CurrentCulture => "da";
|
||||
|
||||
public string Get(string key, string? culture = null)
|
||||
{
|
||||
culture ??= CurrentCulture;
|
||||
var filePath = Path.Combine(_translationsPath, $"{culture}.json");
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
return key;
|
||||
|
||||
var json = File.ReadAllText(filePath);
|
||||
var doc = JsonDocument.Parse(json);
|
||||
|
||||
var parts = key.Split('.');
|
||||
JsonElement current = doc.RootElement;
|
||||
|
||||
foreach (var part in parts)
|
||||
if (!current.TryGetProperty(part, out current))
|
||||
return key;
|
||||
|
||||
return current.GetString() ?? key;
|
||||
}
|
||||
|
||||
public IEnumerable<SupportedCulture> GetSupportedCultures()
|
||||
{
|
||||
return new List<SupportedCulture>
|
||||
{
|
||||
new() { Code = "da", Name = "Danish", NativeName = "Dansk" },
|
||||
new() { Code = "en", Name = "English", NativeName = "English" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"menu": {
|
||||
"home": "Dashboard",
|
||||
"calendar": "Kalender",
|
||||
"pos": "Kasse",
|
||||
"products": "Produkter & Lager",
|
||||
"suppliers": "Leverandører",
|
||||
"customers": "Kunder",
|
||||
"employees": "Medarbejdere",
|
||||
"reports": "Statistik & Rapporter",
|
||||
"settings": "Indstillinger",
|
||||
"account": "Abonnement & Konto"
|
||||
},
|
||||
"groups": {
|
||||
"dashboard": "Dashboard",
|
||||
"data": "Data",
|
||||
"analytics": "Analyse",
|
||||
"system": "System"
|
||||
},
|
||||
"common": {
|
||||
"save": "Gem",
|
||||
"cancel": "Annuller",
|
||||
"search": "Søg",
|
||||
"close": "Luk",
|
||||
"delete": "Slet",
|
||||
"edit": "Rediger",
|
||||
"add": "Tilføj"
|
||||
},
|
||||
"sidebar": {
|
||||
"lockScreen": "Lås skærm",
|
||||
"appName": "Salon OS"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"menu": {
|
||||
"home": "Dashboard",
|
||||
"calendar": "Calendar",
|
||||
"pos": "Point of Sale",
|
||||
"products": "Products & Inventory",
|
||||
"suppliers": "Suppliers",
|
||||
"customers": "Customers",
|
||||
"employees": "Employees",
|
||||
"reports": "Statistics & Reports",
|
||||
"settings": "Settings",
|
||||
"account": "Subscription & Account"
|
||||
},
|
||||
"groups": {
|
||||
"dashboard": "Dashboard",
|
||||
"data": "Data",
|
||||
"analytics": "Analytics",
|
||||
"system": "System"
|
||||
},
|
||||
"common": {
|
||||
"save": "Save",
|
||||
"cancel": "Cancel",
|
||||
"search": "Search",
|
||||
"close": "Close",
|
||||
"delete": "Delete",
|
||||
"edit": "Edit",
|
||||
"add": "Add"
|
||||
},
|
||||
"sidebar": {
|
||||
"lockScreen": "Lock screen",
|
||||
"appName": "Salon OS"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue