mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Finished migration to use gettext (this now closes #161)
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
//TODO: Missing translations should be automatically added to the source POT file
|
||||
Grocy.Translator = new Translator(Grocy.JsGettextTranslatorStrings);
|
||||
Grocy.Translator = new Translator(Grocy.GettextPo);
|
||||
__t = function(text, ...placeholderValues)
|
||||
{
|
||||
if (Grocy.Mode === "dev")
|
||||
{
|
||||
var text2 = text;
|
||||
Grocy.Api.Post('system/log-missing-localization', { "text": text2 });
|
||||
}
|
||||
|
||||
return Grocy.Translator.__(text, ...placeholderValues)
|
||||
}
|
||||
__n = function(number, singularForm, pluralForm)
|
||||
{
|
||||
return Grocy.Translator.n__(singularForm, pluralForm, number)
|
||||
if (Grocy.Mode === "dev")
|
||||
{
|
||||
var singularForm2 = singularForm;
|
||||
Grocy.Api.Post('system/log-missing-localization', { "text": singularForm2 });
|
||||
}
|
||||
|
||||
return Grocy.Translator.n__(singularForm, pluralForm, number, number)
|
||||
}
|
||||
|
||||
U = function(relativePath)
|
||||
|
@@ -154,8 +154,8 @@ function RefreshStatistics()
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-batteries").text(__n(dueCount, __t('%s battery is due to be charged within the next %s days', dueCount, nextXDays), __t('%s batteries are due to be charged within the next %s days', dueCount, nextXDays)));
|
||||
$("#info-overdue-batteries").text(__n(overdueCount, __t('%s battery is overdue to be charged', overdueCount), __t('%s batteries are overdue to be charged', overdueCount)));
|
||||
$("#info-due-batteries").text(__n(dueCount, '%s battery is due to be charged', '%s batteries are due to be charged') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-batteries").text(__n(overdueCount, '%s battery is overdue to be charged', '%s batteries are overdue to be charged'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -154,8 +154,8 @@ function RefreshStatistics()
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-chores").text(__n(dueCount, __t('%s chore is due to be done within the next %s days', dueCount, nextXDays), __t('%s chores are due to be done within the next %s days', dueCount, nextXDays)));
|
||||
$("#info-overdue-chores").text(__n(overdueCount, __t('%s chore is overdue to be done', overdueCount), __t('%s chores are overdue to be done', overdueCount)));
|
||||
$("#info-due-chores").text(__n(dueCount, '%s chore is due to be done', '%s chores are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-chores").text(__n(overdueCount, '%s chore is overdue to be done', '%s chores are overdue to be done'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -265,7 +265,7 @@ function RefreshStatistics()
|
||||
result.forEach(element => {
|
||||
amountSum += parseInt(element.amount);
|
||||
});
|
||||
$("#info-current-stock").text(result.length + " " + __n(result.length, __t('Product'), __t('Products')) + ", " + amountSum.toString() + " " + __n(amountSum, __t('Unit'), __t('Units')));
|
||||
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products') + ", " + __n(amountSum, '%s Unit', '%s Units'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -277,9 +277,9 @@ function RefreshStatistics()
|
||||
Grocy.Api.Get('stock/volatile?expiring_days=' + nextXDays,
|
||||
function(result)
|
||||
{
|
||||
$("#info-expiring-products").text(__n(result.expiring_products.length, __t('%s product expires within the next %s days', result.expiring_products.length, nextXDays), __t('%s products expiring within the next %s days', result.expiring_products.length, nextXDays)));
|
||||
$("#info-expired-products").text(__n(result.expired_products.length, __t('%s product is already expired', result.expired_products.length), __t('%s products are already expired', result.expired_products.length)));
|
||||
$("#info-missing-products").text(__n(result.missing_products.length, __t('%s product is below defined min. stock amount', result.missing_products.length), __t('%s products are below defined min. stock amount', result.missing_products.length)));
|
||||
$("#info-expiring-products").text(__n(result.expiring_products.length, '%s product expires', '%s products expiring') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-expired-products").text(__n(result.expired_products.length, '%s product is already expired', '%s products are already expired'));
|
||||
$("#info-missing-products").text(__n(result.missing_products.length, '%s product is below defined min. stock amount', '%s products are below defined min. stock amount'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -181,8 +181,8 @@ function RefreshStatistics()
|
||||
}
|
||||
});
|
||||
|
||||
$("#info-due-tasks").text(__n(dueCount, __t('%s task is due to be done within the next %s days', dueCount, nextXDays), __t('%s tasks are due to be done within the next %s days', dueCount, nextXDays)));
|
||||
$("#info-overdue-tasks").text(__n(overdueCount, __t('%s task is overdue to be done', overdueCount), __t('%s tasks are overdue to be done', overdueCount)));
|
||||
$("#info-due-tasks").text(__n(dueCount, '%s task is due to be done', '%s tasks are due to be done') + ' ' + __n(nextXDays, 'within the next day', 'within the next %s days'));
|
||||
$("#info-overdue-tasks").text(__n(overdueCount, '%s task is overdue to be done', '%s tasks are overdue to be done'));
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user