diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index f45c7b4b..f231b343 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -47,7 +47,7 @@ ### Meal plan -- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` to only disable the meal plan if not needed (thanks @webysther) +- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` (in `config.php`) to only disable the meal plan if not needed (thanks @webysther) ### Chores @@ -75,6 +75,7 @@ ### General +- Added a new `config.php` setting `ENERGY_UNIT` to customize the label to display energy values (was fixed `kcal` before and defaults to that, so no changed behavior when not configured) - New translations: (thanks all the translators) - Romanian (demo available at ) diff --git a/config-dist.php b/config-dist.php index fa3b47dd..9154c0a5 100644 --- a/config-dist.php +++ b/config-dist.php @@ -41,6 +41,10 @@ Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', ''); // ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.) Setting('CURRENCY', 'USD'); +// Your preferred unit for energy +// E.g. "kcal" or "kJ" or something else (doesn't really matter, it's only used to display energy values) +Setting('ENERGY_UNIT', 'kcal'); + // When running grocy in a subdirectory, this should be set to the relative path, otherwise empty // It needs to be set to the part (of the URL) AFTER the document root, // if URL rewriting is disabled, including index.php diff --git a/localization/strings.pot b/localization/strings.pot index 7f0142ca..62d4c881 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1356,7 +1356,7 @@ msgstr "" msgid "Output" msgstr "" -msgid "Energy (kcal)" +msgid "Energy" msgstr "" msgid "Per stock quantity unit" diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js index 30dc94fa..8e772e88 100644 --- a/public/viewjs/mealplan.js +++ b/public/viewjs/mealplan.js @@ -168,11 +168,11 @@ $(".calendar").each(function() var costsAndCaloriesPerServing = "" if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) { - costsAndCaloriesPerServing = '
' + resolvedRecipe.costs + ' / ' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + ' kcal ' + __t('per serving') + '
'; + costsAndCaloriesPerServing = '
' + resolvedRecipe.costs + ' / ' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + ' ' + Grocy.EnergyUnit + ' ' + __t('per serving') + '
'; } else { - costsAndCaloriesPerServing = '
' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + ' kcal ' + __t('per serving') + '
'; + costsAndCaloriesPerServing = '
' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + ' ' + Grocy.EnergyUnit + ' ' + __t('per serving') + '
'; } if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK) @@ -245,11 +245,11 @@ $(".calendar").each(function() var costsAndCaloriesPerServing = "" if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) { - costsAndCaloriesPerServing = '
' + productDetails.last_price * mealPlanEntry.product_amount + ' / ' + productDetails.product.calories + ' kcal ' + '
'; + costsAndCaloriesPerServing = '
' + productDetails.last_price * mealPlanEntry.product_amount + ' / ' + productDetails.product.calories + ' ' + Grocy.EnergyUnit + '
'; } else { - costsAndCaloriesPerServing = '
' + productDetails.product.calories + ' kcal ' + '
'; + costsAndCaloriesPerServing = '
' + productDetails.product.calories + ' ' + Grocy.EnergyUnit + '
'; } var shoppingListButtonHtml = ""; @@ -302,11 +302,11 @@ $(".calendar").each(function() var costsAndCaloriesPerDay = "" if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) { - costsAndCaloriesPerDay = '
' + dayRecipeResolved.costs + ' / ' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '
'; + costsAndCaloriesPerDay = '
' + dayRecipeResolved.costs + ' / ' + dayRecipeResolved.calories + ' ' + Grocy.EnergyUnit + ' ' + __t('per day') + '
'; } else { - costsAndCaloriesPerDay = '
' + dayRecipeResolved.calories + ' kcal ' + __t('per day') + '
'; + costsAndCaloriesPerDay = '
' + dayRecipeResolved.calories + ' ' + Grocy.EnergyUnit + ' ' + __t('per day') + '
'; } $(".calendar[data-primary-section='true'] .fc-day-header[data-date='" + dayRecipeName + "']").append('
' + costsAndCaloriesPerDay + '
'); diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index b003af32..1009b8ac 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -161,7 +161,7 @@ $('.input-group-qu').on('change', function(e) { $("#tare_weight_qu_info").text($("#qu_id_stock option:selected").text()); $("#quick_consume_qu_info").text($("#qu_id_stock option:selected").text()); - $("#energy_qu_info").text($("#qu_id_stock option:selected").text()); + $("#energy_qu_info").text(Grocy.EnergyUnit + " / " + $("#qu_id_stock option:selected").text()); Grocy.FrontendHelpers.ValidateForm('product-form'); }); diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 7a3b5c40..f4acb23f 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -95,6 +95,7 @@ Grocy.CurrentUrlRelative = "/" + window.location.href.split('?')[0].replace(Grocy.BaseUrl, ""); Grocy.ActiveNav = '@yield('activeNav', '')'; Grocy.Currency = '{{ GROCY_CURRENCY }}'; + Grocy.EnergyUnit = '{{ GROCY_ENERGY_UNIT }}'; Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}'; Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }}; Grocy.LocalizationStrings = {!! $LocalizationStrings !!}; diff --git a/views/productform.blade.php b/views/productform.blade.php index 69eaa024..1ffb123e 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -478,7 +478,7 @@ @php if($mode == 'edit') { $value = $product->calories; } else { $value = 0; } @endphp @include('components.numberpicker', array( 'id' => 'calories', - 'label' => 'Energy (kcal)', + 'label' => 'Energy', 'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts']), 'decimals' => $userSettings['stock_decimal_places_amounts'], 'value' => $value, diff --git a/views/recipes.blade.php b/views/recipes.blade.php index 23c6f45e..35b117b2 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -388,7 +388,7 @@
@if(!empty($calories) && intval($calories) > 0)
-   +