Move language/country settings to app config

Moves the language and country dicts from the config model to json files
that are loaded during app init and stored in the app config dict. This
substantially improves the readability of the config model and allows
for much more sensible loading of the language/country options.
This commit is contained in:
Ben Busby 2020-12-17 16:39:35 -05:00
parent d4a4a03de1
commit 6e7ec9918a
No known key found for this signature in database
GPG Key ID: 3B08611DF6E62ED2
7 changed files with 309 additions and 309 deletions

View File

@ -3,6 +3,7 @@ from app.utils.session_utils import generate_user_keys
from app.utils.gen_ddg_bangs import gen_bangs_json
from flask import Flask
from flask_session import Session
import json
import os
from stem import Signal
@ -17,6 +18,10 @@ app.config['VERSION_NUMBER'] = '0.2.1'
app.config['APP_ROOT'] = os.getenv(
'APP_ROOT',
os.path.dirname(os.path.abspath(__file__)))
app.config['LANGUAGES'] = json.load(open(
os.path.join(app.config['APP_ROOT'], '../misc/languages.json')))
app.config['COUNTRIES'] = json.load(open(
os.path.join(app.config['APP_ROOT'], '../misc/countries.json')))
app.config['STATIC_FOLDER'] = os.getenv(
'STATIC_FOLDER',
os.path.join(app.config['APP_ROOT'], 'static'))

View File

@ -111,8 +111,8 @@ class Filter:
return
# Wrap section in details element to allow collapse/expand
details = BeautifulSoup('html.parser').new_tag('details')
summary = BeautifulSoup('html.parser').new_tag('summary')
details = BeautifulSoup(features='lxml').new_tag('details')
summary = BeautifulSoup(features='lxml').new_tag('summary')
summary.string = question_divs[0].find('h2').text
question_divs[0].find('h2').decompose()
details.append(summary)

View File

@ -1,305 +1,4 @@
class Config:
# Derived from here:
# https://sites.google.com/site/tomihasa/google-language-codes#searchlanguage
LANGUAGES = [
{'name': 'Default (none specified)', 'value': ''},
{'name': 'English', 'value': 'lang_en'},
{'name': 'Afrikaans', 'value': 'lang_af'},
{'name': 'Arabic', 'value': 'lang_ar'},
{'name': 'Armenian', 'value': 'lang_hy'},
{'name': 'Belarusian', 'value': 'lang_be'},
{'name': 'Bulgarian', 'value': 'lang_bg'},
{'name': 'Catalan', 'value': 'lang_ca'},
{'name': 'Chinese (Simplified)', 'value': 'lang_zh-CN'},
{'name': 'Chinese (Traditional)', 'value': 'lang_zh-TW'},
{'name': 'Croatian', 'value': 'lang_hr'},
{'name': 'Czech', 'value': 'lang_cs'},
{'name': 'Danish', 'value': 'lang_da'},
{'name': 'Dutch', 'value': 'lang_nl'},
{'name': 'Esperanto', 'value': 'lang_eo'},
{'name': 'Estonian', 'value': 'lang_et'},
{'name': 'Filipino', 'value': 'lang_tl'},
{'name': 'Finnish', 'value': 'lang_fi'},
{'name': 'French', 'value': 'lang_fr'},
{'name': 'German', 'value': 'lang_de'},
{'name': 'Greek', 'value': 'lang_el'},
{'name': 'Hebrew', 'value': 'lang_iw'},
{'name': 'Hindi', 'value': 'lang_hi'},
{'name': 'Hungarian', 'value': 'lang_hu'},
{'name': 'Icelandic', 'value': 'lang_is'},
{'name': 'Indonesian', 'value': 'lang_id'},
{'name': 'Italian', 'value': 'lang_it'},
{'name': 'Japanese', 'value': 'lang_ja'},
{'name': 'Korean', 'value': 'lang_ko'},
{'name': 'Latvian', 'value': 'lang_lv'},
{'name': 'Lithuanian', 'value': 'lang_lt'},
{'name': 'Norwegian', 'value': 'lang_no'},
{'name': 'Persian', 'value': 'lang_fa'},
{'name': 'Polish', 'value': 'lang_pl'},
{'name': 'Portuguese', 'value': 'lang_pt'},
{'name': 'Romanian', 'value': 'lang_ro'},
{'name': 'Russian', 'value': 'lang_ru'},
{'name': 'Serbian', 'value': 'lang_sr'},
{'name': 'Slovak', 'value': 'lang_sk'},
{'name': 'Slovenian', 'value': 'lang_sl'},
{'name': 'Spanish', 'value': 'lang_es'},
{'name': 'Swahili', 'value': 'lang_sw'},
{'name': 'Swedish', 'value': 'lang_sv'},
{'name': 'Thai', 'value': 'lang_th'},
{'name': 'Turkish', 'value': 'lang_tr'},
{'name': 'Ukrainian', 'value': 'lang_uk'},
{'name': 'Vietnamese', 'value': 'lang_vi'},
]
COUNTRIES = [
{'name': 'Default (none)', 'value': ''},
{'name': 'Afghanistan', 'value': 'countryAF'},
{'name': 'Albania', 'value': 'countryAL'},
{'name': 'Algeria', 'value': 'countryDZ'},
{'name': 'American Samoa', 'value': 'countryAS'},
{'name': 'Andorra', 'value': 'countryAD'},
{'name': 'Angola', 'value': 'countryAO'},
{'name': 'Anguilla', 'value': 'countryAI'},
{'name': 'Antarctica', 'value': 'countryAQ'},
{'name': 'Antigua and Barbuda', 'value': 'countryAG'},
{'name': 'Argentina', 'value': 'countryAR'},
{'name': 'Armenia', 'value': 'countryAM'},
{'name': 'Aruba', 'value': 'countryAW'},
{'name': 'Australia', 'value': 'countryAU'},
{'name': 'Austria', 'value': 'countryAT'},
{'name': 'Azerbaijan', 'value': 'countryAZ'},
{'name': 'Bahamas', 'value': 'countryBS'},
{'name': 'Bahrain', 'value': 'countryBH'},
{'name': 'Bangladesh', 'value': 'countryBD'},
{'name': 'Barbados', 'value': 'countryBB'},
{'name': 'Belarus', 'value': 'countryBY'},
{'name': 'Belgium', 'value': 'countryBE'},
{'name': 'Belize', 'value': 'countryBZ'},
{'name': 'Benin', 'value': 'countryBJ'},
{'name': 'Bermuda', 'value': 'countryBM'},
{'name': 'Bhutan', 'value': 'countryBT'},
{'name': 'Bolivia', 'value': 'countryBO'},
{'name': 'Bosnia and Herzegovina', 'value': 'countryBA'},
{'name': 'Botswana', 'value': 'countryBW'},
{'name': 'Bouvet Island', 'value': 'countryBV'},
{'name': 'Brazil', 'value': 'countryBR'},
{'name': 'British Indian Ocean Territory', 'value': 'countryIO'},
{'name': 'Brunei Darussalam', 'value': 'countryBN'},
{'name': 'Bulgaria', 'value': 'countryBG'},
{'name': 'Burkina Faso', 'value': 'countryBF'},
{'name': 'Burundi', 'value': 'countryBI'},
{'name': 'Cambodia', 'value': 'countryKH'},
{'name': 'Cameroon', 'value': 'countryCM'},
{'name': 'Canada', 'value': 'countryCA'},
{'name': 'Cape Verde', 'value': 'countryCV'},
{'name': 'Cayman Islands', 'value': 'countryKY'},
{'name': 'Central African Republic', 'value': 'countryCF'},
{'name': 'Chad', 'value': 'countryTD'},
{'name': 'Chile', 'value': 'countryCL'},
{'name': 'China', 'value': 'countryCN'},
{'name': 'Christmas Island', 'value': 'countryCX'},
{'name': 'Cocos (Keeling) Islands', 'value': 'countryCC'},
{'name': 'Colombia', 'value': 'countryCO'},
{'name': 'Comoros', 'value': 'countryKM'},
{'name': 'Congo', 'value': 'countryCG'},
{'name': 'Congo, Democratic Republic of the', 'value': 'countryCD'},
{'name': 'Cook Islands', 'value': 'countryCK'},
{'name': 'Costa Rica', 'value': 'countryCR'},
{'name': 'Cote D\'ivoire', 'value': 'countryCI'},
{'name': 'Croatia (Hrvatska)', 'value': 'countryHR'},
{'name': 'Cuba', 'value': 'countryCU'},
{'name': 'Cyprus', 'value': 'countryCY'},
{'name': 'Czech Republic', 'value': 'countryCZ'},
{'name': 'Denmark', 'value': 'countryDK'},
{'name': 'Djibouti', 'value': 'countryDJ'},
{'name': 'Dominica', 'value': 'countryDM'},
{'name': 'Dominican Republic', 'value': 'countryDO'},
{'name': 'East Timor', 'value': 'countryTP'},
{'name': 'Ecuador', 'value': 'countryEC'},
{'name': 'Egypt', 'value': 'countryEG'},
{'name': 'El Salvador', 'value': 'countrySV'},
{'name': 'Equatorial Guinea', 'value': 'countryGQ'},
{'name': 'Eritrea', 'value': 'countryER'},
{'name': 'Estonia', 'value': 'countryEE'},
{'name': 'Ethiopia', 'value': 'countryET'},
{'name': 'European Union', 'value': 'countryEU'},
{'name': 'Falkland Islands (Malvinas)', 'value': 'countryFK'},
{'name': 'Faroe Islands', 'value': 'countryFO'},
{'name': 'Fiji', 'value': 'countryFJ'},
{'name': 'Finland', 'value': 'countryFI'},
{'name': 'France', 'value': 'countryFR'},
{'name': r'France\, Metropolitan', 'value': 'countryFX'},
{'name': 'French Guiana', 'value': 'countryGF'},
{'name': 'French Polynesia', 'value': 'countryPF'},
{'name': 'French Southern Territories', 'value': 'countryTF'},
{'name': 'Gabon', 'value': 'countryGA'},
{'name': 'Gambia', 'value': 'countryGM'},
{'name': 'Georgia', 'value': 'countryGE'},
{'name': 'Germany', 'value': 'countryDE'},
{'name': 'Ghana', 'value': 'countryGH'},
{'name': 'Gibraltar', 'value': 'countryGI'},
{'name': 'Greece', 'value': 'countryGR'},
{'name': 'Greenland', 'value': 'countryGL'},
{'name': 'Grenada', 'value': 'countryGD'},
{'name': 'Guadeloupe', 'value': 'countryGP'},
{'name': 'Guam', 'value': 'countryGU'},
{'name': 'Guatemala', 'value': 'countryGT'},
{'name': 'Guinea', 'value': 'countryGN'},
{'name': 'Guinea-Bissau', 'value': 'countryGW'},
{'name': 'Guyana', 'value': 'countryGY'},
{'name': 'Haiti', 'value': 'countryHT'},
{'name': 'Heard Island and Mcdonald Islands', 'value': 'countryHM'},
{'name': 'Holy See (Vatican City State)', 'value': 'countryVA'},
{'name': 'Honduras', 'value': 'countryHN'},
{'name': 'Hong Kong', 'value': 'countryHK'},
{'name': 'Hungary', 'value': 'countryHU'},
{'name': 'Iceland', 'value': 'countryIS'},
{'name': 'India', 'value': 'countryIN'},
{'name': 'Indonesia', 'value': 'countryID'},
{'name': 'Iran, Islamic Republic of', 'value': 'countryIR'},
{'name': 'Iraq', 'value': 'countryIQ'},
{'name': 'Ireland', 'value': 'countryIE'},
{'name': 'Israel', 'value': 'countryIL'},
{'name': 'Italy', 'value': 'countryIT'},
{'name': 'Jamaica', 'value': 'countryJM'},
{'name': 'Japan', 'value': 'countryJP'},
{'name': 'Jordan', 'value': 'countryJO'},
{'name': 'Kazakhstan', 'value': 'countryKZ'},
{'name': 'Kenya', 'value': 'countryKE'},
{'name': 'Kiribati', 'value': 'countryKI'},
{'name': 'Korea, Democratic People\'s Republic of',
'value': 'countryKP'},
{'name': 'Korea, Republic of', 'value': 'countryKR'},
{'name': 'Kuwait', 'value': 'countryKW'},
{'name': 'Kyrgyzstan', 'value': 'countryKG'},
{'name': 'Lao People\'s Democratic Republic', 'value': 'countryLA'},
{'name': 'Latvia', 'value': 'countryLV'},
{'name': 'Lebanon', 'value': 'countryLB'},
{'name': 'Lesotho', 'value': 'countryLS'},
{'name': 'Liberia', 'value': 'countryLR'},
{'name': 'Libyan Arab Jamahiriya', 'value': 'countryLY'},
{'name': 'Liechtenstein', 'value': 'countryLI'},
{'name': 'Lithuania', 'value': 'countryLT'},
{'name': 'Luxembourg', 'value': 'countryLU'},
{'name': 'Macao', 'value': 'countryMO'},
{'name': 'Macedonia, the Former Yugosalv Republic of',
'value': 'countryMK'},
{'name': 'Madagascar', 'value': 'countryMG'},
{'name': 'Malawi', 'value': 'countryMW'},
{'name': 'Malaysia', 'value': 'countryMY'},
{'name': 'Maldives', 'value': 'countryMV'},
{'name': 'Mali', 'value': 'countryML'},
{'name': 'Malta', 'value': 'countryMT'},
{'name': 'Marshall Islands', 'value': 'countryMH'},
{'name': 'Martinique', 'value': 'countryMQ'},
{'name': 'Mauritania', 'value': 'countryMR'},
{'name': 'Mauritius', 'value': 'countryMU'},
{'name': 'Mayotte', 'value': 'countryYT'},
{'name': 'Mexico', 'value': 'countryMX'},
{'name': 'Micronesia, Federated States of', 'value': 'countryFM'},
{'name': 'Moldova, Republic of', 'value': 'countryMD'},
{'name': 'Monaco', 'value': 'countryMC'},
{'name': 'Mongolia', 'value': 'countryMN'},
{'name': 'Montserrat', 'value': 'countryMS'},
{'name': 'Morocco', 'value': 'countryMA'},
{'name': 'Mozambique', 'value': 'countryMZ'},
{'name': 'Myanmar', 'value': 'countryMM'},
{'name': 'Namibia', 'value': 'countryNA'},
{'name': 'Nauru', 'value': 'countryNR'},
{'name': 'Nepal', 'value': 'countryNP'},
{'name': 'Netherlands', 'value': 'countryNL'},
{'name': 'Netherlands Antilles', 'value': 'countryAN'},
{'name': 'New Caledonia', 'value': 'countryNC'},
{'name': 'New Zealand', 'value': 'countryNZ'},
{'name': 'Nicaragua', 'value': 'countryNI'},
{'name': 'Niger', 'value': 'countryNE'},
{'name': 'Nigeria', 'value': 'countryNG'},
{'name': 'Niue', 'value': 'countryNU'},
{'name': 'Norfolk Island', 'value': 'countryNF'},
{'name': 'Northern Mariana Islands', 'value': 'countryMP'},
{'name': 'Norway', 'value': 'countryNO'},
{'name': 'Oman', 'value': 'countryOM'},
{'name': 'Pakistan', 'value': 'countryPK'},
{'name': 'Palau', 'value': 'countryPW'},
{'name': 'Palestinian Territory', 'value': 'countryPS'},
{'name': 'Panama', 'value': 'countryPA'},
{'name': 'Papua New Guinea', 'value': 'countryPG'},
{'name': 'Paraguay', 'value': 'countryPY'},
{'name': 'Peru', 'value': 'countryPE'},
{'name': 'Philippines', 'value': 'countryPH'},
{'name': 'Pitcairn', 'value': 'countryPN'},
{'name': 'Poland', 'value': 'countryPL'},
{'name': 'Portugal', 'value': 'countryPT'},
{'name': 'Puerto Rico', 'value': 'countryPR'},
{'name': 'Qatar', 'value': 'countryQA'},
{'name': 'Reunion', 'value': 'countryRE'},
{'name': 'Romania', 'value': 'countryRO'},
{'name': 'Russian Federation', 'value': 'countryRU'},
{'name': 'Rwanda', 'value': 'countryRW'},
{'name': 'Saint Helena', 'value': 'countrySH'},
{'name': 'Saint Kitts and Nevis', 'value': 'countryKN'},
{'name': 'Saint Lucia', 'value': 'countryLC'},
{'name': 'Saint Pierre and Miquelon', 'value': 'countryPM'},
{'name': 'Saint Vincent and the Grenadines', 'value': 'countryVC'},
{'name': 'Samoa', 'value': 'countryWS'},
{'name': 'San Marino', 'value': 'countrySM'},
{'name': 'Sao Tome and Principe', 'value': 'countryST'},
{'name': 'Saudi Arabia', 'value': 'countrySA'},
{'name': 'Senegal', 'value': 'countrySN'},
{'name': 'Serbia and Montenegro', 'value': 'countryCS'},
{'name': 'Seychelles', 'value': 'countrySC'},
{'name': 'Sierra Leone', 'value': 'countrySL'},
{'name': 'Singapore', 'value': 'countrySG'},
{'name': 'Slovakia', 'value': 'countrySK'},
{'name': 'Slovenia', 'value': 'countrySI'},
{'name': 'Solomon Islands', 'value': 'countrySB'},
{'name': 'Somalia', 'value': 'countrySO'},
{'name': 'South Africa', 'value': 'countryZA'},
{'name': 'South Georgia and the South Sandwich Islands',
'value': 'countryGS'},
{'name': 'Spain', 'value': 'countryES'},
{'name': 'Sri Lanka', 'value': 'countryLK'},
{'name': 'Sudan', 'value': 'countrySD'},
{'name': 'Suriname', 'value': 'countrySR'},
{'name': 'Svalbard and Jan Mayen', 'value': 'countrySJ'},
{'name': 'Swaziland', 'value': 'countrySZ'},
{'name': 'Sweden', 'value': 'countrySE'},
{'name': 'Switzerland', 'value': 'countryCH'},
{'name': 'Syrian Arab Republic', 'value': 'countrySY'},
{'name': 'Taiwan, Province of China', 'value': 'countryTW'},
{'name': 'Tajikistan', 'value': 'countryTJ'},
{'name': 'Tanzania, United Republic of', 'value': 'countryTZ'},
{'name': 'Thailand', 'value': 'countryTH'},
{'name': 'Togo', 'value': 'countryTG'},
{'name': 'Tokelau', 'value': 'countryTK'},
{'name': 'Tonga', 'value': 'countryTO'},
{'name': 'Trinidad and Tobago', 'value': 'countryTT'},
{'name': 'Tunisia', 'value': 'countryTN'},
{'name': 'Turkey', 'value': 'countryTR'},
{'name': 'Turkmenistan', 'value': 'countryTM'},
{'name': 'Turks and Caicos Islands', 'value': 'countryTC'},
{'name': 'Tuvalu', 'value': 'countryTV'},
{'name': 'Uganda', 'value': 'countryUG'},
{'name': 'Ukraine', 'value': 'countryUA'},
{'name': 'United Arab Emirates', 'value': 'countryAE'},
{'name': 'United Kingdom', 'value': 'countryUK'},
{'name': 'United States', 'value': 'countryUS'},
{'name': 'United States Minor Outlying Islands', 'value': 'countryUM'},
{'name': 'Uruguay', 'value': 'countryUY'},
{'name': 'Uzbekistan', 'value': 'countryUZ'},
{'name': 'Vanuatu', 'value': 'countryVU'},
{'name': 'Venezuela', 'value': 'countryVE'},
{'name': 'Vietnam', 'value': 'countryVN'},
{'name': 'Virgin Islands, British', 'value': 'countryVG'},
{'name': 'Virgin Islands, U.S.', 'value': 'countryVI'},
{'name': 'Wallis and Futuna', 'value': 'countryWF'},
{'name': 'Western Sahara', 'value': 'countryEH'},
{'name': 'Yemen', 'value': 'countryYE'},
{'name': 'Yugoslavia', 'value': 'countryYU'},
{'name': 'Zambia', 'value': 'countryZM'},
{'name': 'Zimbabwe', 'value': 'countryZW'}
]
def __init__(self, **kwargs):
self.url = ''
self.lang_search = ''

View File

@ -131,8 +131,8 @@ def index():
session['error_message'] = ''
return render_template('index.html',
languages=Config.LANGUAGES,
countries=Config.COUNTRIES,
languages=app.config['LANGUAGES'],
countries=app.config['COUNTRIES'],
config=g.user_config,
error_message=error_message,
tor_available=int(os.environ.get('TOR_AVAILABLE')),

248
misc/countries.json Normal file
View File

@ -0,0 +1,248 @@
[
{"name": "Default (none)", "value": ""},
{"name": "Afghanistan", "value": "countryAF"},
{"name": "Albania", "value": "countryAL"},
{"name": "Algeria", "value": "countryDZ"},
{"name": "American Samoa", "value": "countryAS"},
{"name": "Andorra", "value": "countryAD"},
{"name": "Angola", "value": "countryAO"},
{"name": "Anguilla", "value": "countryAI"},
{"name": "Antarctica", "value": "countryAQ"},
{"name": "Antigua and Barbuda", "value": "countryAG"},
{"name": "Argentina", "value": "countryAR"},
{"name": "Armenia", "value": "countryAM"},
{"name": "Aruba", "value": "countryAW"},
{"name": "Australia", "value": "countryAU"},
{"name": "Austria", "value": "countryAT"},
{"name": "Azerbaijan", "value": "countryAZ"},
{"name": "Bahamas", "value": "countryBS"},
{"name": "Bahrain", "value": "countryBH"},
{"name": "Bangladesh", "value": "countryBD"},
{"name": "Barbados", "value": "countryBB"},
{"name": "Belarus", "value": "countryBY"},
{"name": "Belgium", "value": "countryBE"},
{"name": "Belize", "value": "countryBZ"},
{"name": "Benin", "value": "countryBJ"},
{"name": "Bermuda", "value": "countryBM"},
{"name": "Bhutan", "value": "countryBT"},
{"name": "Bolivia", "value": "countryBO"},
{"name": "Bosnia and Herzegovina", "value": "countryBA"},
{"name": "Botswana", "value": "countryBW"},
{"name": "Bouvet Island", "value": "countryBV"},
{"name": "Brazil", "value": "countryBR"},
{"name": "British Indian Ocean Territory", "value": "countryIO"},
{"name": "Brunei Darussalam", "value": "countryBN"},
{"name": "Bulgaria", "value": "countryBG"},
{"name": "Burkina Faso", "value": "countryBF"},
{"name": "Burundi", "value": "countryBI"},
{"name": "Cambodia", "value": "countryKH"},
{"name": "Cameroon", "value": "countryCM"},
{"name": "Canada", "value": "countryCA"},
{"name": "Cape Verde", "value": "countryCV"},
{"name": "Cayman Islands", "value": "countryKY"},
{"name": "Central African Republic", "value": "countryCF"},
{"name": "Chad", "value": "countryTD"},
{"name": "Chile", "value": "countryCL"},
{"name": "China", "value": "countryCN"},
{"name": "Christmas Island", "value": "countryCX"},
{"name": "Cocos (Keeling) Islands", "value": "countryCC"},
{"name": "Colombia", "value": "countryCO"},
{"name": "Comoros", "value": "countryKM"},
{"name": "Congo", "value": "countryCG"},
{"name": "Congo, Democratic Republic of the", "value": "countryCD"},
{"name": "Cook Islands", "value": "countryCK"},
{"name": "Costa Rica", "value": "countryCR"},
{"name": "Cote D\"ivoire", "value": "countryCI"},
{"name": "Croatia (Hrvatska)", "value": "countryHR"},
{"name": "Cuba", "value": "countryCU"},
{"name": "Cyprus", "value": "countryCY"},
{"name": "Czech Republic", "value": "countryCZ"},
{"name": "Denmark", "value": "countryDK"},
{"name": "Djibouti", "value": "countryDJ"},
{"name": "Dominica", "value": "countryDM"},
{"name": "Dominican Republic", "value": "countryDO"},
{"name": "East Timor", "value": "countryTP"},
{"name": "Ecuador", "value": "countryEC"},
{"name": "Egypt", "value": "countryEG"},
{"name": "El Salvador", "value": "countrySV"},
{"name": "Equatorial Guinea", "value": "countryGQ"},
{"name": "Eritrea", "value": "countryER"},
{"name": "Estonia", "value": "countryEE"},
{"name": "Ethiopia", "value": "countryET"},
{"name": "European Union", "value": "countryEU"},
{"name": "Falkland Islands (Malvinas)", "value": "countryFK"},
{"name": "Faroe Islands", "value": "countryFO"},
{"name": "Fiji", "value": "countryFJ"},
{"name": "Finland", "value": "countryFI"},
{"name": "France", "value": "countryFR"},
{"name": "France, Metropolitan", "value": "countryFX"},
{"name": "French Guiana", "value": "countryGF"},
{"name": "French Polynesia", "value": "countryPF"},
{"name": "French Southern Territories", "value": "countryTF"},
{"name": "Gabon", "value": "countryGA"},
{"name": "Gambia", "value": "countryGM"},
{"name": "Georgia", "value": "countryGE"},
{"name": "Germany", "value": "countryDE"},
{"name": "Ghana", "value": "countryGH"},
{"name": "Gibraltar", "value": "countryGI"},
{"name": "Greece", "value": "countryGR"},
{"name": "Greenland", "value": "countryGL"},
{"name": "Grenada", "value": "countryGD"},
{"name": "Guadeloupe", "value": "countryGP"},
{"name": "Guam", "value": "countryGU"},
{"name": "Guatemala", "value": "countryGT"},
{"name": "Guinea", "value": "countryGN"},
{"name": "Guinea-Bissau", "value": "countryGW"},
{"name": "Guyana", "value": "countryGY"},
{"name": "Haiti", "value": "countryHT"},
{"name": "Heard Island and Mcdonald Islands", "value": "countryHM"},
{"name": "Holy See (Vatican City State)", "value": "countryVA"},
{"name": "Honduras", "value": "countryHN"},
{"name": "Hong Kong", "value": "countryHK"},
{"name": "Hungary", "value": "countryHU"},
{"name": "Iceland", "value": "countryIS"},
{"name": "India", "value": "countryIN"},
{"name": "Indonesia", "value": "countryID"},
{"name": "Iran, Islamic Republic of", "value": "countryIR"},
{"name": "Iraq", "value": "countryIQ"},
{"name": "Ireland", "value": "countryIE"},
{"name": "Israel", "value": "countryIL"},
{"name": "Italy", "value": "countryIT"},
{"name": "Jamaica", "value": "countryJM"},
{"name": "Japan", "value": "countryJP"},
{"name": "Jordan", "value": "countryJO"},
{"name": "Kazakhstan", "value": "countryKZ"},
{"name": "Kenya", "value": "countryKE"},
{"name": "Kiribati", "value": "countryKI"},
{"name": "Korea, Democratic People\"s Republic of",
"value": "countryKP"},
{"name": "Korea, Republic of", "value": "countryKR"},
{"name": "Kuwait", "value": "countryKW"},
{"name": "Kyrgyzstan", "value": "countryKG"},
{"name": "Lao People\"s Democratic Republic", "value": "countryLA"},
{"name": "Latvia", "value": "countryLV"},
{"name": "Lebanon", "value": "countryLB"},
{"name": "Lesotho", "value": "countryLS"},
{"name": "Liberia", "value": "countryLR"},
{"name": "Libyan Arab Jamahiriya", "value": "countryLY"},
{"name": "Liechtenstein", "value": "countryLI"},
{"name": "Lithuania", "value": "countryLT"},
{"name": "Luxembourg", "value": "countryLU"},
{"name": "Macao", "value": "countryMO"},
{"name": "Macedonia, the Former Yugosalv Republic of",
"value": "countryMK"},
{"name": "Madagascar", "value": "countryMG"},
{"name": "Malawi", "value": "countryMW"},
{"name": "Malaysia", "value": "countryMY"},
{"name": "Maldives", "value": "countryMV"},
{"name": "Mali", "value": "countryML"},
{"name": "Malta", "value": "countryMT"},
{"name": "Marshall Islands", "value": "countryMH"},
{"name": "Martinique", "value": "countryMQ"},
{"name": "Mauritania", "value": "countryMR"},
{"name": "Mauritius", "value": "countryMU"},
{"name": "Mayotte", "value": "countryYT"},
{"name": "Mexico", "value": "countryMX"},
{"name": "Micronesia, Federated States of", "value": "countryFM"},
{"name": "Moldova, Republic of", "value": "countryMD"},
{"name": "Monaco", "value": "countryMC"},
{"name": "Mongolia", "value": "countryMN"},
{"name": "Montserrat", "value": "countryMS"},
{"name": "Morocco", "value": "countryMA"},
{"name": "Mozambique", "value": "countryMZ"},
{"name": "Myanmar", "value": "countryMM"},
{"name": "Namibia", "value": "countryNA"},
{"name": "Nauru", "value": "countryNR"},
{"name": "Nepal", "value": "countryNP"},
{"name": "Netherlands", "value": "countryNL"},
{"name": "Netherlands Antilles", "value": "countryAN"},
{"name": "New Caledonia", "value": "countryNC"},
{"name": "New Zealand", "value": "countryNZ"},
{"name": "Nicaragua", "value": "countryNI"},
{"name": "Niger", "value": "countryNE"},
{"name": "Nigeria", "value": "countryNG"},
{"name": "Niue", "value": "countryNU"},
{"name": "Norfolk Island", "value": "countryNF"},
{"name": "Northern Mariana Islands", "value": "countryMP"},
{"name": "Norway", "value": "countryNO"},
{"name": "Oman", "value": "countryOM"},
{"name": "Pakistan", "value": "countryPK"},
{"name": "Palau", "value": "countryPW"},
{"name": "Palestinian Territory", "value": "countryPS"},
{"name": "Panama", "value": "countryPA"},
{"name": "Papua New Guinea", "value": "countryPG"},
{"name": "Paraguay", "value": "countryPY"},
{"name": "Peru", "value": "countryPE"},
{"name": "Philippines", "value": "countryPH"},
{"name": "Pitcairn", "value": "countryPN"},
{"name": "Poland", "value": "countryPL"},
{"name": "Portugal", "value": "countryPT"},
{"name": "Puerto Rico", "value": "countryPR"},
{"name": "Qatar", "value": "countryQA"},
{"name": "Reunion", "value": "countryRE"},
{"name": "Romania", "value": "countryRO"},
{"name": "Russian Federation", "value": "countryRU"},
{"name": "Rwanda", "value": "countryRW"},
{"name": "Saint Helena", "value": "countrySH"},
{"name": "Saint Kitts and Nevis", "value": "countryKN"},
{"name": "Saint Lucia", "value": "countryLC"},
{"name": "Saint Pierre and Miquelon", "value": "countryPM"},
{"name": "Saint Vincent and the Grenadines", "value": "countryVC"},
{"name": "Samoa", "value": "countryWS"},
{"name": "San Marino", "value": "countrySM"},
{"name": "Sao Tome and Principe", "value": "countryST"},
{"name": "Saudi Arabia", "value": "countrySA"},
{"name": "Senegal", "value": "countrySN"},
{"name": "Serbia and Montenegro", "value": "countryCS"},
{"name": "Seychelles", "value": "countrySC"},
{"name": "Sierra Leone", "value": "countrySL"},
{"name": "Singapore", "value": "countrySG"},
{"name": "Slovakia", "value": "countrySK"},
{"name": "Slovenia", "value": "countrySI"},
{"name": "Solomon Islands", "value": "countrySB"},
{"name": "Somalia", "value": "countrySO"},
{"name": "South Africa", "value": "countryZA"},
{"name": "South Georgia and the South Sandwich Islands",
"value": "countryGS"},
{"name": "Spain", "value": "countryES"},
{"name": "Sri Lanka", "value": "countryLK"},
{"name": "Sudan", "value": "countrySD"},
{"name": "Suriname", "value": "countrySR"},
{"name": "Svalbard and Jan Mayen", "value": "countrySJ"},
{"name": "Swaziland", "value": "countrySZ"},
{"name": "Sweden", "value": "countrySE"},
{"name": "Switzerland", "value": "countryCH"},
{"name": "Syrian Arab Republic", "value": "countrySY"},
{"name": "Taiwan, Province of China", "value": "countryTW"},
{"name": "Tajikistan", "value": "countryTJ"},
{"name": "Tanzania, United Republic of", "value": "countryTZ"},
{"name": "Thailand", "value": "countryTH"},
{"name": "Togo", "value": "countryTG"},
{"name": "Tokelau", "value": "countryTK"},
{"name": "Tonga", "value": "countryTO"},
{"name": "Trinidad and Tobago", "value": "countryTT"},
{"name": "Tunisia", "value": "countryTN"},
{"name": "Turkey", "value": "countryTR"},
{"name": "Turkmenistan", "value": "countryTM"},
{"name": "Turks and Caicos Islands", "value": "countryTC"},
{"name": "Tuvalu", "value": "countryTV"},
{"name": "Uganda", "value": "countryUG"},
{"name": "Ukraine", "value": "countryUA"},
{"name": "United Arab Emirates", "value": "countryAE"},
{"name": "United Kingdom", "value": "countryUK"},
{"name": "United States", "value": "countryUS"},
{"name": "United States Minor Outlying Islands", "value": "countryUM"},
{"name": "Uruguay", "value": "countryUY"},
{"name": "Uzbekistan", "value": "countryUZ"},
{"name": "Vanuatu", "value": "countryVU"},
{"name": "Venezuela", "value": "countryVE"},
{"name": "Vietnam", "value": "countryVN"},
{"name": "Virgin Islands, British", "value": "countryVG"},
{"name": "Virgin Islands, U.S.", "value": "countryVI"},
{"name": "Wallis and Futuna", "value": "countryWF"},
{"name": "Western Sahara", "value": "countryEH"},
{"name": "Yemen", "value": "countryYE"},
{"name": "Yugoslavia", "value": "countryYU"},
{"name": "Zambia", "value": "countryZM"},
{"name": "Zimbabwe", "value": "countryZW"}
]

49
misc/languages.json Normal file
View File

@ -0,0 +1,49 @@
[
{"name": "Default (none specified)", "value": ""},
{"name": "English", "value": "lang_en"},
{"name": "Afrikaans", "value": "lang_af"},
{"name": "Arabic", "value": "lang_ar"},
{"name": "Armenian", "value": "lang_hy"},
{"name": "Belarusian", "value": "lang_be"},
{"name": "Bulgarian", "value": "lang_bg"},
{"name": "Catalan", "value": "lang_ca"},
{"name": "Chinese (Simplified)", "value": "lang_zh-CN"},
{"name": "Chinese (Traditional)", "value": "lang_zh-TW"},
{"name": "Croatian", "value": "lang_hr"},
{"name": "Czech", "value": "lang_cs"},
{"name": "Danish", "value": "lang_da"},
{"name": "Dutch", "value": "lang_nl"},
{"name": "Esperanto", "value": "lang_eo"},
{"name": "Estonian", "value": "lang_et"},
{"name": "Filipino", "value": "lang_tl"},
{"name": "Finnish", "value": "lang_fi"},
{"name": "French", "value": "lang_fr"},
{"name": "German", "value": "lang_de"},
{"name": "Greek", "value": "lang_el"},
{"name": "Hebrew", "value": "lang_iw"},
{"name": "Hindi", "value": "lang_hi"},
{"name": "Hungarian", "value": "lang_hu"},
{"name": "Icelandic", "value": "lang_is"},
{"name": "Indonesian", "value": "lang_id"},
{"name": "Italian", "value": "lang_it"},
{"name": "Japanese", "value": "lang_ja"},
{"name": "Korean", "value": "lang_ko"},
{"name": "Latvian", "value": "lang_lv"},
{"name": "Lithuanian", "value": "lang_lt"},
{"name": "Norwegian", "value": "lang_no"},
{"name": "Persian", "value": "lang_fa"},
{"name": "Polish", "value": "lang_pl"},
{"name": "Portuguese", "value": "lang_pt"},
{"name": "Romanian", "value": "lang_ro"},
{"name": "Russian", "value": "lang_ru"},
{"name": "Serbian", "value": "lang_sr"},
{"name": "Slovak", "value": "lang_sk"},
{"name": "Slovenian", "value": "lang_sl"},
{"name": "Spanish", "value": "lang_es"},
{"name": "Swahili", "value": "lang_sw"},
{"name": "Swedish", "value": "lang_sv"},
{"name": "Thai", "value": "lang_th"},
{"name": "Turkish", "value": "lang_tr"},
{"name": "Ukrainian", "value": "lang_uk"},
{"name": "Vietnamese", "value": "lang_vi"}
]

View File

@ -1,5 +1,4 @@
from app import app
from app.models.config import Config
from app.utils.session_utils import generate_user_keys
import pytest
import random
@ -8,9 +7,9 @@ demo_config = {
'near': random.choice(['Seattle', 'New York', 'San Francisco']),
'dark_mode': str(random.getrandbits(1)),
'nojs': str(random.getrandbits(1)),
'lang_interface': random.choice(Config.LANGUAGES)['value'],
'lang_search': random.choice(Config.LANGUAGES)['value'],
'ctry': random.choice(Config.COUNTRIES)['value']
'lang_interface': random.choice(app.config['LANGUAGES'])['value'],
'lang_search': random.choice(app.config['LANGUAGES'])['value'],
'ctry': random.choice(app.config['COUNTRIES'])['value']
}