1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 09:07:12 -05:00

More localization of recipe search and view

This commit is contained in:
MaxJa4
2022-02-28 21:19:00 +01:00
parent b393d026f7
commit 1e3a6fadf0
6 changed files with 17 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import re
from html import unescape
from unicodedata import decomposition
from django.utils.translation import gettext as _
from django.utils.dateparse import parse_duration
from isodate import parse_duration as iso_parse_duration
from isodate.isoerror import ISO8601Error
@@ -147,7 +148,7 @@ def get_from_scraper(scrape, request):
if scrape.url:
recipe_json['url'] = scrape.url
recipe_json['recipeInstructions'] += "\n\nImported from " + scrape.url
recipe_json['recipeInstructions'] += "\n\n" + _("Imported from") + ": " + scrape.url
return recipe_json

View File

@@ -4,6 +4,7 @@ from zipfile import ZipFile
from bs4 import BeautifulSoup
from django.utils.translation import gettext as _
from cookbook.helper.ingredient_parser import IngredientParser
from cookbook.helper.recipe_html_import import get_recipe_from_source
from cookbook.helper.recipe_url_import import iso_duration_to_minutes, parse_servings
@@ -60,7 +61,7 @@ class CopyMeThat(Integration):
try:
if file.find("a", {"id": "original_link"}).text != '':
step.instruction += "\n\nImported from: " + file.find("a", {"id": "original_link"}).text
step.instruction += "\n\n" + _("Imported from") + ": " + file.find("a", {"id": "original_link"}).text
step.save()
except AttributeError:
pass

View File

@@ -6,6 +6,7 @@ from zipfile import ZipFile
import requests
from django.utils.translation import gettext as _
from cookbook.helper.image_processing import get_filetype
from cookbook.helper.ingredient_parser import IngredientParser
from cookbook.integration.integration import Integration
@@ -49,7 +50,7 @@ class RecetteTek(Integration):
# Append the original import url to the step (if it exists)
try:
if file['url'] != '':
step.instruction += '\n\nImported from: ' + file['url']
step.instruction += '\n\n' + _('Imported from') + ': ' + file['url']
step.save()
except Exception as e:
print(recipe.name, ': failed to import source url ', str(e))

View File

@@ -4,6 +4,7 @@ from zipfile import ZipFile
from bs4 import BeautifulSoup
from django.utils.translation import gettext as _
from cookbook.helper.ingredient_parser import IngredientParser
from cookbook.helper.recipe_url_import import iso_duration_to_minutes, parse_servings
from cookbook.integration.integration import Integration
@@ -59,7 +60,7 @@ class RecipeKeeper(Integration):
step.instruction += s.text + ' \n'
if file.find("span", {"itemprop": "recipeSource"}).text != '':
step.instruction += "\n\nImported from: " + file.find("span", {"itemprop": "recipeSource"}).text
step.instruction += "\n\n" + _("Imported from") + ": " + file.find("span", {"itemprop": "recipeSource"}).text
step.save()
recipe.steps.add(step)