Browser-cache localization strings (+ new API endpoint to get them)

This commit is contained in:
Bernd Bestel
2021-06-29 20:24:02 +02:00
parent d18a8d8b56
commit b856911f0f
8 changed files with 52 additions and 10 deletions

View File

@@ -226,7 +226,22 @@ Grocy.Api.DeleteFile = function(fileName, group, success, error)
xhr.send();
};
Grocy.Translator = new Translator(Grocy.GettextPo);
U = function(relativePath)
{
return Grocy.BaseUrl.replace(/\/$/, '') + relativePath;
}
Grocy.Translator = new Translator(); // Dummy, real instance is loaded async below
Grocy.Api.Get("system/localization-strings?v=" + Grocy.Version,
function(response)
{
Grocy.Translator = new Translator(response);
},
function(xhr)
{
console.error(xhr);
}
);
__t = function(text, ...placeholderValues)
{
if (Grocy.Mode === "dev")
@@ -248,11 +263,6 @@ __n = function(number, singularForm, pluralForm)
return Grocy.Translator.n__(singularForm, pluralForm, number, number)
}
U = function(relativePath)
{
return Grocy.BaseUrl.replace(/\/$/, '') + relativePath;
}
if (!Grocy.ActiveNav.isEmpty())
{
var menuItem = $('#sidebarResponsive').find("[data-nav-for-page='" + Grocy.ActiveNav + "']");