Add test for validating translation language keys

Also adds Spanish translation to json (the only non-English language I
can add and reasonably validate on my own).
This commit is contained in:
Ben Busby 2021-05-24 14:13:17 -04:00
parent 041689d637
commit eacc7126b5
No known key found for this signature in database
GPG Key ID: 3B08611DF6E62ED2
3 changed files with 38 additions and 4 deletions

View File

@ -10,13 +10,13 @@ class Config:
return bool(int(val))
return False
self.app_config = current_app.config
app_config = current_app.config
self.url = os.getenv('WHOOGLE_CONFIG_URL', '')
self.lang_search = os.getenv('WHOOGLE_CONFIG_SEARCH_LANGUAGE', '')
self.lang_interface = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '')
self.style = os.getenv(
'WHOOGLE_CONFIG_STYLE',
open(os.path.join(self.app_config['STATIC_FOLDER'],
open(os.path.join(app_config['STATIC_FOLDER'],
'css/variables.css')).read())
self.block = os.getenv('WHOOGLE_CONFIG_BLOCK', '')
self.ctry = os.getenv('WHOOGLE_CONFIG_COUNTRY', '')
@ -85,7 +85,7 @@ class Config:
str -- the localization language string
"""
if (self.lang_interface and
self.lang_interface in self.app_config['TRANSLATIONS']):
self.lang_interface in current_app.config['TRANSLATIONS']):
return self.lang_interface
return 'lang_en'

View File

@ -1,6 +1,5 @@
{
"lang_en": {
"default-none": "Default (none specified)",
"search": "Search",
"config": "Configuration",
"config-country": "Filter Results by Country",
@ -27,5 +26,33 @@
"apply": "Apply",
"save-as": "Save As...",
"github-link": "View on GitHub"
},
"lang_es": {
"search": "Buscar",
"config": "Configuración",
"config-country": "Filtrar Resultados por País",
"config-country-help": "Nota: Si está habilitado, un sitio web solo aparecerá en los resultados de búsqueda si está alojado en ese país.",
"config-lang": "Idioma de Interfaz",
"config-lang-search": "Idioma de Búsqueda",
"config-near": "Cerca",
"config-near-help": "Nombre de la Ciudad",
"config-block": "Bloquear",
"config-block-help": "Lista de sitios separados por comas",
"config-nojs": "Mostrar Enlaces NoJS",
"config-dark": "Modo Oscuro",
"config-safe": "Búsqueda Segura",
"config-alts": "Reemplazar Enlaces de Redes Sociales",
"config-alts-help": "Reemplaza los enlaces de Twitter/YouTube/Instagram/etc con alternativas que respetan la privacidad.",
"config-new-tab": "Abrir enlaces en una pestaña nueva",
"config-images": "Búsqueda de imágenes a tamaño completo",
"config-images-help": "(Experimental) Agrega la opción 'Ver imagen' a las búsquedas de imágenes de escritorio. Esto hará que las miniaturas de los resultados de la imagen aparezcan con una resolución más baja.",
"config-tor": "Usa Tor",
"config-get-only": "GET solo solicitudes",
"config-url": "URL raíz",
"config-css": "CSS personalizado",
"load": "Cargar",
"apply": "Aplicar",
"save-as": "Guardar como...",
"github-link": "Ver en GitHub"
}
}

View File

@ -1,5 +1,6 @@
from cryptography.fernet import Fernet
from app import app
from app.utils.session import generate_user_key, valid_user_session
@ -15,6 +16,12 @@ def test_valid_session(client):
assert valid_user_session(session)
def test_valid_translation_keys(client):
valid_lang_keys = [_['value'] for _ in app.config['LANGUAGES']]
for translation_key in app.config['TRANSLATIONS']:
assert translation_key in valid_lang_keys
def test_query_decryption(client):
# FIXME: Handle decryption errors in search.py and rewrite test
# This previously was used to test swapping decryption keys between