Separate interface language from search language in env vars
The search language is now set using the WHOOGLE_CONFIG_SEARCH_LANGUAGE environment variable. Interface language is still set using WHOOGLE_CONFIG_LANGUAGE. Fixes #260main
parent
f56e913521
commit
8ae7b5947e
|
@ -259,9 +259,10 @@ There are a few optional environment variables available for customizing a Whoog
|
||||||
These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time.
|
These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time.
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ----------------------- | --------------------------------------------------------------- |
|
| ------------------------------ | --------------------------------------------------------------- |
|
||||||
| WHOOGLE_CONFIG_COUNTRY | Filter results by hosting country |
|
| WHOOGLE_CONFIG_COUNTRY | Filter results by hosting country |
|
||||||
| WHOOGLE_CONFIG_LANGUAGE | Set interface and search result language |
|
| WHOOGLE_CONFIG_LANGUAGE | Set interface language |
|
||||||
|
| WHOOGLE_CONFIG_SEARCH_LANGUAGE | Set search result language |
|
||||||
| WHOOGLE_CONFIG_DARK | Enable dark theme |
|
| WHOOGLE_CONFIG_DARK | Enable dark theme |
|
||||||
| WHOOGLE_CONFIG_SAFE | Enable safe searches |
|
| WHOOGLE_CONFIG_SAFE | Enable safe searches |
|
||||||
| WHOOGLE_CONFIG_ALTS | Use social media site alternatives (nitter, invidious, etc) |
|
| WHOOGLE_CONFIG_ALTS | Use social media site alternatives (nitter, invidious, etc) |
|
||||||
|
@ -269,7 +270,7 @@ These environment variables allow setting default config values, but can be over
|
||||||
| WHOOGLE_CONFIG_NEW_TAB | Always open results in new tab |
|
| WHOOGLE_CONFIG_NEW_TAB | Always open results in new tab |
|
||||||
| WHOOGLE_CONFIG_GET_ONLY | Search using GET requests only |
|
| WHOOGLE_CONFIG_GET_ONLY | Search using GET requests only |
|
||||||
| WHOOGLE_CONFIG_URL | The root url of the instance (`https://<your url>/`) |
|
| WHOOGLE_CONFIG_URL | The root url of the instance (`https://<your url>/`) |
|
||||||
| WHOOGLE_CONFIG_STYLE | The custom CSS to use for styling (must be single line) |
|
| WHOOGLE_CONFIG_STYLE | The custom CSS to use for styling (should be single line) |
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Same as most search engines, with the exception of filtering by time range.
|
Same as most search engines, with the exception of filtering by time range.
|
||||||
|
|
7
app.json
7
app.json
|
@ -71,7 +71,12 @@
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
"WHOOGLE_CONFIG_LANGUAGE": {
|
"WHOOGLE_CONFIG_LANGUAGE": {
|
||||||
"description": "[CONFIG] The language to use for search results and interface (use values from https://raw.githubusercontent.com/benbusby/whoogle-search/develop/app/static/settings/languages.json)",
|
"description": "[CONFIG] The language to use for the interface (use values from https://raw.githubusercontent.com/benbusby/whoogle-search/develop/app/static/settings/languages.json)",
|
||||||
|
"value": "",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
"WHOOGLE_CONFIG_SEARCH_LANGUAGE": {
|
||||||
|
"description": "[CONFIG] The language to use for search results (use values from https://raw.githubusercontent.com/benbusby/whoogle-search/develop/app/static/settings/languages.json)",
|
||||||
"value": "",
|
"value": "",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Config:
|
||||||
|
|
||||||
app_config = current_app.config
|
app_config = current_app.config
|
||||||
self.url = os.getenv('WHOOGLE_CONFIG_URL', '')
|
self.url = os.getenv('WHOOGLE_CONFIG_URL', '')
|
||||||
self.lang_search = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '')
|
self.lang_search = os.getenv('WHOOGLE_CONFIG_SEARCH_LANGUAGE', '')
|
||||||
self.lang_interface = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '')
|
self.lang_interface = os.getenv('WHOOGLE_CONFIG_LANGUAGE', '')
|
||||||
self.style = os.getenv(
|
self.style = os.getenv(
|
||||||
'WHOOGLE_CONFIG_STYLE',
|
'WHOOGLE_CONFIG_STYLE',
|
||||||
|
@ -36,11 +36,12 @@ class Config:
|
||||||
|
|
||||||
# Skip setting custom config if there isn't one
|
# Skip setting custom config if there isn't one
|
||||||
if kwargs:
|
if kwargs:
|
||||||
for attr in self.get_mutable_attrs():
|
mutable_attrs = self.get_mutable_attrs()
|
||||||
if attr not in kwargs.keys():
|
for attr in mutable_attrs:
|
||||||
setattr(self, attr, '')
|
if attr in kwargs.keys():
|
||||||
else:
|
|
||||||
setattr(self, attr, kwargs[attr])
|
setattr(self, attr, kwargs[attr])
|
||||||
|
elif attr not in kwargs.keys() and mutable_attrs[attr] == bool:
|
||||||
|
setattr(self, attr, False)
|
||||||
|
|
||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
@ -55,7 +56,7 @@ class Config:
|
||||||
return hasattr(self, name)
|
return hasattr(self, name)
|
||||||
|
|
||||||
def get_mutable_attrs(self):
|
def get_mutable_attrs(self):
|
||||||
return {name: attr for name, attr in self.__dict__.items()
|
return {name: type(attr) for name, attr in self.__dict__.items()
|
||||||
if not name.startswith("__")
|
if not name.startswith("__")
|
||||||
and (type(attr) is bool or type(attr) is str)}
|
and (type(attr) is bool or type(attr) is str)}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#WHOOGLE_CONFIG_COUNTRY=countryUK # See app/static/settings/countries.json for values
|
#WHOOGLE_CONFIG_COUNTRY=countryUK # See app/static/settings/countries.json for values
|
||||||
#WHOOGLE_CONFIG_LANGUAGE=lang_en # See app/static/settings/languages.json for values
|
#WHOOGLE_CONFIG_LANGUAGE=lang_en # See app/static/settings/languages.json for values
|
||||||
|
#WHOOGLE_CONFIG_SEARCH_LANGUAGE=lang_en # See app/static/settings/languages.json for values
|
||||||
#WHOOGLE_CONFIG_DARK=1 # Dark mode
|
#WHOOGLE_CONFIG_DARK=1 # Dark mode
|
||||||
#WHOOGLE_CONFIG_SAFE=1 # Safe searches
|
#WHOOGLE_CONFIG_SAFE=1 # Safe searches
|
||||||
#WHOOGLE_CONFIG_ALTS=1 # Use social media site alternatives
|
#WHOOGLE_CONFIG_ALTS=1 # Use social media site alternatives
|
||||||
|
|
Loading…
Reference in New Issue