Finished migration to use gettext (this now closes #161)

This commit is contained in:
Bernd Bestel
2019-05-02 20:20:18 +02:00
parent 5d3f248d94
commit 4912dd56d1
75 changed files with 2275 additions and 1581 deletions

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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)
{