Multilanguage support for CicloPi stations sorting settings
This commit is contained in:
parent
1676d8040b
commit
5232911709
@ -85,6 +85,67 @@ default_ciclopi_messages = {
|
|||||||
'it': "🧭"
|
'it': "🧭"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'sorting': {
|
||||||
|
'center': {
|
||||||
|
'name': {
|
||||||
|
'en': "City center",
|
||||||
|
'it': "Borgo"
|
||||||
|
},
|
||||||
|
'description': {
|
||||||
|
'en': "sorted by distance from city center (Borgo Stretto "
|
||||||
|
" station.)",
|
||||||
|
'it': "in ordine di distanza crescente da Borgo Stretto."
|
||||||
|
},
|
||||||
|
'short_description': {
|
||||||
|
'en': "by distance from city center",
|
||||||
|
'it': "per distanza da Borgo Stretto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'alphabetical': {
|
||||||
|
'name': {
|
||||||
|
'en': "Alphabetical",
|
||||||
|
'it': "Alfabetico"
|
||||||
|
},
|
||||||
|
'description': {
|
||||||
|
'en': "in alphabetical order.",
|
||||||
|
'it': "in ordine alfabetico."
|
||||||
|
},
|
||||||
|
'short_description': {
|
||||||
|
'en': "by name",
|
||||||
|
'it': "per nome"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'position': {
|
||||||
|
'name': {
|
||||||
|
'en': "Position",
|
||||||
|
'it': "Posizione"
|
||||||
|
},
|
||||||
|
'description': {
|
||||||
|
'en': "sorted by distance from last set position. "
|
||||||
|
"City center position is set by default.",
|
||||||
|
'it': "in ordine di distanza crescente dall'ultima posizione "
|
||||||
|
"inviata. Di default sarà Borgo Stretto."
|
||||||
|
},
|
||||||
|
'short_description': {
|
||||||
|
'en': "by distance",
|
||||||
|
'it': "per distanza"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'custom': {
|
||||||
|
'name': {
|
||||||
|
'en': "Favourites",
|
||||||
|
'it': "Preferite"
|
||||||
|
},
|
||||||
|
'description': {
|
||||||
|
'en': "sorted by custom order.",
|
||||||
|
'it': "nell'ordine che hai scelto."
|
||||||
|
},
|
||||||
|
'short_description': {
|
||||||
|
'en': "customly ordered",
|
||||||
|
'it': "in ordine personalizzato"
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,28 +168,19 @@ UNIT_TO_KM = {
|
|||||||
|
|
||||||
CICLOPI_SORTING_CHOICES = {
|
CICLOPI_SORTING_CHOICES = {
|
||||||
0: dict(
|
0: dict(
|
||||||
name='Borgo',
|
id='center',
|
||||||
description='in ordine di distanza crescente da Borgo Stretto.',
|
|
||||||
short_description='per distanza da Borgo Stretto',
|
|
||||||
symbol='🏛'
|
symbol='🏛'
|
||||||
),
|
),
|
||||||
1: dict(
|
1: dict(
|
||||||
name='Alfabetico',
|
id='alphabetical',
|
||||||
description='in ordine alfabetico.',
|
|
||||||
short_description='per nome',
|
|
||||||
symbol='🔤'
|
symbol='🔤'
|
||||||
),
|
),
|
||||||
2: dict(
|
2: dict(
|
||||||
name='Posizione',
|
id='position',
|
||||||
description='in ordine di distanza crescente dall\'ultima posizione '
|
|
||||||
'inviata. Di default sarà Borgo Stretto.',
|
|
||||||
short_description='per distanza',
|
|
||||||
symbol='🧭'
|
symbol='🧭'
|
||||||
),
|
),
|
||||||
3: dict(
|
3: dict(
|
||||||
name='Preferite',
|
id='custom',
|
||||||
description='nell\'ordine che hai scelto.',
|
|
||||||
short_description='in ordine personalizzato',
|
|
||||||
symbol='⭐️'
|
symbol='⭐️'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -754,7 +806,7 @@ async def _ciclopi_command(bot, update, user_record, sent_message=None,
|
|||||||
):
|
):
|
||||||
stations = stations[:stations_to_show]
|
stations = stations[:stations_to_show]
|
||||||
text = (
|
text = (
|
||||||
"🚲 Stazioni ciclopi {sort[short_description]}"
|
"🚲 Stazioni ciclopi {order}"
|
||||||
"{lim} {sort[symbol]}\n"
|
"{lim} {sort[symbol]}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"{s}"
|
"{s}"
|
||||||
@ -767,6 +819,12 @@ async def _ciclopi_command(bot, update, user_record, sent_message=None,
|
|||||||
else "<i>- Nessuna stazione -</i>"
|
else "<i>- Nessuna stazione -</i>"
|
||||||
),
|
),
|
||||||
sort=CICLOPI_SORTING_CHOICES[sorting_code],
|
sort=CICLOPI_SORTING_CHOICES[sorting_code],
|
||||||
|
order=bot.get_message(
|
||||||
|
'ciclopi', 'sorting',
|
||||||
|
CICLOPI_SORTING_CHOICES[sorting_code]['id'],
|
||||||
|
'short_description',
|
||||||
|
user_record=user_record, update=update
|
||||||
|
),
|
||||||
lim=(
|
lim=(
|
||||||
" ({adv} le preferite)".format(
|
" ({adv} le preferite)".format(
|
||||||
adv='prima' if show_all else 'solo'
|
adv='prima' if show_all else 'solo'
|
||||||
@ -939,8 +997,16 @@ async def _ciclopi_button_sort(bot, update, user_record, arguments):
|
|||||||
"Scegli una nuova modalità o torna all'elenco delle stazioni."
|
"Scegli una nuova modalità o torna all'elenco delle stazioni."
|
||||||
).format(
|
).format(
|
||||||
options='\n'.join(
|
options='\n'.join(
|
||||||
"- {c[symbol]} {c[name]}: {c[description]}".format(
|
"- {symbol} {name}: {description}".format(
|
||||||
c=choice
|
symbol=choice['symbol'],
|
||||||
|
name=bot.get_message(
|
||||||
|
'ciclopi', 'sorting', choice['id'], 'name',
|
||||||
|
user_record=user_record, update=update
|
||||||
|
),
|
||||||
|
description=bot.get_message(
|
||||||
|
'ciclopi', 'sorting', choice['id'], 'description',
|
||||||
|
user_record=user_record, update=update
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for choice in CICLOPI_SORTING_CHOICES.values()
|
for choice in CICLOPI_SORTING_CHOICES.values()
|
||||||
)
|
)
|
||||||
@ -948,12 +1014,16 @@ async def _ciclopi_button_sort(bot, update, user_record, arguments):
|
|||||||
reply_markup = make_inline_keyboard(
|
reply_markup = make_inline_keyboard(
|
||||||
[
|
[
|
||||||
make_button(
|
make_button(
|
||||||
text="{s} {c[name]} {c[symbol]}".format(
|
text="{s} {name} {c[symbol]}".format(
|
||||||
c=choice,
|
c=choice,
|
||||||
s=(
|
s=(
|
||||||
'✅'
|
'✅'
|
||||||
if code == ciclopi_record['sorting']
|
if code == ciclopi_record['sorting']
|
||||||
else '☑️'
|
else '☑️'
|
||||||
|
),
|
||||||
|
name=bot.get_message(
|
||||||
|
'ciclopi', 'sorting', choice['id'], 'name',
|
||||||
|
user_record=user_record, update=update
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
prefix='ciclopi:///',
|
prefix='ciclopi:///',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user