mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
web proxy: not less code but better strucuture
Find out which directory we want and keep it in an array. Use the first one that exists and ignore the others. This allows us to do a late fallback into "en" language on top which wasn't handled gracefully before.
This commit is contained in:
parent
cee33f5393
commit
c404e662fa
@ -468,19 +468,20 @@ cache_mgr {{OPNsense.proxy.general.VisibleEmail}}
|
||||
# Set connection timeout
|
||||
connect_timeout {{OPNsense.proxy.general.connecttimeout}} seconds
|
||||
{% endif %}
|
||||
|
||||
# Set error directory language
|
||||
{% set lang = namespace(dirs = [], done = false) %}
|
||||
{% if not helpers.empty('OPNsense.proxy.general.error_pages') %}
|
||||
error_directory /usr/local/etc/squid/errors/local
|
||||
{% do lang.dirs.append('/usr/local/etc/squid/errors/local') %}
|
||||
{% elif helpers.exists('system.language') and system.language != "" %}
|
||||
{% set langdir = system.language|lower|replace('_', '-') %}
|
||||
{% if helpers.file_exists('/usr/local/share/squid-langpack/' + langdir) %}
|
||||
error_directory /usr/local/share/squid-langpack/{{ langdir }}
|
||||
{% else %}
|
||||
{% set langdir = langdir[:2] %}
|
||||
{% if helpers.file_exists('/usr/local/share/squid-langpack/' + langdir) %}
|
||||
error_directory /usr/local/share/squid-langpack/{{ langdir }}
|
||||
{% else %}
|
||||
error_directory /usr/local/etc/squid/errors/local
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% set langdir = system.language|lower|replace('_', '-') %}
|
||||
{% do lang.dirs.append('/usr/local/share/squid-langpack/' + langdir) %}
|
||||
{% do lang.dirs.append('/usr/local/share/squid-langpack/' + langdir[:2]) %}
|
||||
{% endif %}
|
||||
{% do lang.dirs.append('/usr/local/share/squid-langpack/en') %}
|
||||
{% for langdir in lang.dirs %}
|
||||
{% if not lang.done and helpers.file_exists(langdir) %}
|
||||
{% set lang.done = true %}
|
||||
error_directory {{ langdir }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user