Skip to content

Commit

Permalink
refactor(locales): massive string renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Jun 15, 2024
1 parent 1f21d95 commit cd2dd7a
Show file tree
Hide file tree
Showing 479 changed files with 1,530 additions and 1,566 deletions.
18 changes: 12 additions & 6 deletions eduu/plugins/admins/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def ban(c: Client, m: Message, strings):
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
if check_admin.status in ADMIN_STATUSES:
await m.reply_text(strings("i_cant_ban_admins"))
await m.reply_text(strings("ban_cannot_ban_admins"))
return

await m.chat.ban_member(target_user.id)
Expand All @@ -28,7 +28,9 @@ async def ban(c: Client, m: Message, strings):
admin=m.from_user.mention,
)
if reason:
await m.reply_text(text + "\n" + strings("reason_string").format(reason_text=reason))
await m.reply_text(
text + "\n" + strings("admins_reason_string").format(reason_text=reason)
)
else:
await m.reply_text(text)

Expand All @@ -41,7 +43,7 @@ async def kick(c: Client, m: Message, strings):
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
if check_admin.status in ADMIN_STATUSES:
await m.reply_text(strings("i_cant_kick_admins"))
await m.reply_text(strings("kick_cannot_kick_admins"))
return

await m.chat.ban_member(target_user.id)
Expand All @@ -51,7 +53,9 @@ async def kick(c: Client, m: Message, strings):
admin=m.from_user.mention,
)
if reason:
await m.reply_text(text + "\n" + strings("reason_string").format(reason_text=reason))
await m.reply_text(
text + "\n" + strings("admins_reason_string").format(reason_text=reason)
)
else:
await m.reply_text(text)

Expand All @@ -68,7 +72,9 @@ async def unban(c: Client, m: Message, strings):
admin=m.from_user.mention,
)
if reason:
await m.reply_text(text + "\n" + strings("reason_string").format(reason_text=reason))
await m.reply_text(
text + "\n" + strings("admins_reason_string").format(reason_text=reason)
)
else:
await m.reply_text(text)

Expand All @@ -78,7 +84,7 @@ async def unban(c: Client, m: Message, strings):
@require_admin(ChatPrivileges(can_restrict_members=True))
async def tban(c: Client, m: Message, strings):
if len(m.command) == 1:
await m.reply_text(strings("error_must_specify_time").format(command=m.command[0]))
await m.reply_text(strings("admins_error_must_specify_time").format(command=m.command[0]))
return

split_time = m.text.split(None, 1)
Expand Down
12 changes: 8 additions & 4 deletions eduu/plugins/admins/mutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def mute(c: Client, m: Message, strings):
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
if check_admin.status in ADMIN_STATUSES:
await m.reply_text(strings("i_cant_mute_admins"))
await m.reply_text(strings("mute_cannot_mute_admins"))
return

await m.chat.restrict_member(target_user.id, ChatPermissions(can_send_messages=False))
Expand All @@ -28,7 +28,9 @@ async def mute(c: Client, m: Message, strings):
admin=m.from_user.mention,
)
if reason:
await m.reply_text(text + "\n" + strings("reason_string").format(reason_text=reason))
await m.reply_text(
text + "\n" + strings("admins_reason_string").format(reason_text=reason)
)
else:
await m.reply_text(text)

Expand All @@ -45,7 +47,9 @@ async def unmute(c: Client, m: Message, strings):
admin=m.from_user.mention,
)
if reason:
await m.reply_text(text + "\n" + strings("reason_string").format(reason_text=reason))
await m.reply_text(
text + "\n" + strings("admins_reason_string").format(reason_text=reason)
)
else:
await m.reply_text(text)

Expand All @@ -55,7 +59,7 @@ async def unmute(c: Client, m: Message, strings):
@require_admin(ChatPrivileges(can_restrict_members=True))
async def tmute(c: Client, m: Message, strings):
if len(m.command) == 1:
await m.reply_text(strings("error_must_specify_time").format(command=m.command[0]))
await m.reply_text(strings("admins_error_must_specify_time").format(command=m.command[0]))
return

split_time = m.text.split(None, 1)
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ async def cat(c: Client, m: Message, strings):
rj = r.json()

if rj[0]["url"].endswith(".gif"):
await m.reply_animation(rj[0]["url"], caption=strings("meow"))
await m.reply_animation(rj[0]["url"], caption=strings("cat_meow"))
else:
await m.reply_photo(rj[0]["url"], caption=strings("meow"))
await m.reply_photo(rj[0]["url"], caption=strings("cat_meow"))


commands.add_command("cat", "general")
24 changes: 8 additions & 16 deletions eduu/plugins/cmds_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def gen_categories_kb(strings_manager):
return [
[
InlineKeyboardButton(
strings_manager(category, context="cmds_list"),
strings_manager(f"cmds_category_{category}"),
callback_data=f"view_category {category}",
)
for category in categories
Expand All @@ -36,14 +36,10 @@ async def cmds_list(c: Client, m: CallbackQuery, strings):
keyboard = InlineKeyboardMarkup(
inline_keyboard=[
*gen_categories_kb(strings),
[
InlineKeyboardButton(
strings("back_btn", context="general"), callback_data="start_back"
)
],
[InlineKeyboardButton(strings("general_back_btn"), callback_data="start_back")],
]
)
await m.message.edit_text(strings("select_command_category"), reply_markup=keyboard)
await m.message.edit_text(strings("cmds_list_select_category"), reply_markup=keyboard)


@Client.on_message(filters.command(["help", "start help"]) & filters.private)
Expand All @@ -55,13 +51,13 @@ async def show_private_help(c: Client, m: Message, strings):
*gen_categories_kb(strings),
[
InlineKeyboardButton(
strings("back_btn", context="general"),
strings("general_back_btn"),
callback_data="start_back",
)
],
]
)
await m.reply_text(strings("select_command_category"), reply_markup=keyboard)
await m.reply_text(strings("cmds_list_select_category"), reply_markup=keyboard)


@Client.on_message(filters.command(["help", "start help"]))
Expand All @@ -72,13 +68,13 @@ async def show_help(c: Client, m: Message, strings):
inline_keyboard=[
[
InlineKeyboardButton(
strings("start_chat", context="start"),
strings("start_chat"),
url=f"https://t.me/{c.me.username}?start=help",
)
]
]
)
await m.reply_text(strings("group_help"), reply_markup=keyboard)
await m.reply_text(strings("cmds_list_group_help"), reply_markup=keyboard)


@Client.on_callback_query(filters.regex("^view_category .+"))
Expand All @@ -87,11 +83,7 @@ async def get_category(c: Client, m: CallbackQuery, strings):
msg = commands.get_commands_message(strings, m.data.split(maxsplit=1)[1])
keyboard = InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
strings("back_btn", context="general"), callback_data="commands"
)
]
[InlineKeyboardButton(strings("general_back_btn"), callback_data="commands")]
]
)
await m.message.edit_text(msg, reply_markup=keyboard)
2 changes: 1 addition & 1 deletion eduu/plugins/coub.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def coub(c: Client, m: Message, strings):
links = content["permalink"]
title = content["title"]
except IndexError:
await m.reply_text(strings("no_results", context="general"))
await m.reply_text(strings("general_no_results"))
else:
await m.reply_text(f'<b><a href="https://coub.com/v/{links}">{title}</a></b>')

Expand Down
10 changes: 6 additions & 4 deletions eduu/plugins/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def save_filter(c: Client, m: Message, strings):
trigger = split_text[0].lower()

if m.reply_to_message is None and len(split_text) < 2:
await m.reply_text(strings("add_filter_empty"), quote=True)
await m.reply_text(strings("filters_add_empty"), quote=True)
return

if m.reply_to_message and m.reply_to_message.photo:
Expand Down Expand Up @@ -87,7 +87,7 @@ async def save_filter(c: Client, m: Message, strings):
else:
await add_filter(chat_id, trigger, raw_data, file_id, filter_type)

await m.reply_text(strings("add_filter_success").format(trigger=trigger), quote=True)
await m.reply_text(strings("filters_add_success").format(trigger=trigger), quote=True)


@Client.on_message(filters.command(["delfilter", "rmfilter", "stop"], PREFIXES))
Expand All @@ -100,11 +100,13 @@ async def delete_filter(c: Client, m: Message, strings):
check_filter = await check_for_filters(chat_id, trigger)

if not check_filter:
await m.reply_text(strings("no_filter_with_name").format(trigger=trigger), quote=True)
await m.reply_text(
strings("filters_no_filter_with_name").format(trigger=trigger), quote=True
)
return

await rm_filter(chat_id, trigger)
await m.reply_text(strings("remove_filter_success").format(trigger=trigger), quote=True)
await m.reply_text(strings("filters_remove_success").format(trigger=trigger), quote=True)


@Client.on_message(filters.command("filters", PREFIXES))
Expand Down
2 changes: 1 addition & 1 deletion eduu/plugins/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@use_chat_lang
async def dice(c: Client, m: Message, strings):
dicen = await c.send_dice(m.chat.id, reply_to_message_id=m.id)
await dicen.reply_text(strings("result").format(number=dicen.dice.value), quote=True)
await dicen.reply_text(strings("dice_result").format(number=dicen.dice.value), quote=True)


commands.add_command("dice", "general")
2 changes: 1 addition & 1 deletion eduu/plugins/dogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def dog(c: Client, m: Message, strings):
r = await http.get("https://random.dog/woof.json")
rj = r.json()

await m.reply_photo(rj["url"], caption=strings("woof"))
await m.reply_photo(rj["url"], caption=strings("dog_woof"))


commands.add_command("dog", "general")
2 changes: 1 addition & 1 deletion eduu/plugins/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def gif(c: Client, m: Message, strings):
)
rjson = r.json()
if not rjson["results"]:
await m.reply_text(strings("no_results", context="general"))
await m.reply_text(strings("general_no_results"))
return

res = rjson["results"][0]["media"][0]["mediumgif"]["url"]
Expand Down
6 changes: 3 additions & 3 deletions eduu/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
@use_chat_lang
async def git(c: Client, m: Message, strings):
if len(m.command) == 1:
await m.reply_text(strings("no_username_err"), reply_to_message_id=m.id)
await m.reply_text(strings("git_no_username"), reply_to_message_id=m.id)
return

text = m.text.split(maxsplit=1)[1]
req = await http.get(f"https://api.github.com/users/{text}")
res = req.json()

if not res.get("login"):
await m.reply_text(strings("not_found_user"), reply_to_message_id=m.id)
await m.reply_text(strings("git_user_not_found"), reply_to_message_id=m.id)
return

avatar = res["avatar_url"]

anticache = quote_plus((await http.head(avatar)).headers["Last-Modified"])

caption_text = strings("info_git_user")
caption_text = strings("git_user_info")
await m.reply_photo(
avatar + anticache,
caption=caption_text.format(
Expand Down
24 changes: 12 additions & 12 deletions eduu/plugins/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ async def ids_private(c: Client, m: Message, strings):
int(m.command[1]) if m.command[1].isdecimal() else m.command[1]
)
except BadRequest:
await m.reply_text(strings("user_not_found").format(user=m.command[1]))
await m.reply_text(strings("id_user_not_found").format(user=m.command[1]))
return
else:
user_data = m.from_user

await m.reply_text(
strings("info_private").format(
strings("id_info_private").format(
first_name=user_data.first_name,
last_name=user_data.last_name or "",
username=f"@{user_data.username}" if user_data.username else strings("none"),
username=f"@{user_data.username}" if user_data.username else strings("id_none"),
user_id=user_data.id,
user_dc=user_data.dc_id or strings("unknown"),
lang=user_data.language_code or strings("unknown"),
user_dc=user_data.dc_id or strings("id_unknown"),
lang=user_data.language_code or strings("id_unknown"),
chat_type=m.chat.type,
)
)
Expand All @@ -48,7 +48,7 @@ async def ids(c: Client, m: Message, strings):
int(m.command[1]) if m.command[1].isdecimal() else m.command[1]
)
except BadRequest:
await m.reply_text(strings("user_not_found").format(user=m.command[1]))
await m.reply_text(strings("id_user_not_found").format(user=m.command[1]))
return

elif m.reply_to_message:
Expand All @@ -57,17 +57,17 @@ async def ids(c: Client, m: Message, strings):
user_data = m.from_user

await m.reply_text(
strings("info_group").format(
strings("id_info_group").format(
first_name=html.escape(user_data.first_name),
last_name=html.escape(user_data.last_name or ""),
username=f"@{user_data.username}" if user_data.username else strings("none"),
username=f"@{user_data.username}" if user_data.username else strings("id_none"),
user_id=user_data.id,
user_dc=user_data.dc_id or strings("unknown"),
lang=user_data.language_code or strings("unknown"),
user_dc=user_data.dc_id or strings("id_unknown"),
lang=user_data.language_code or strings("id_unknown"),
chat_title=m.chat.title,
chat_username=f"@{m.chat.username}" if m.chat.username else strings("none"),
chat_username=f"@{m.chat.username}" if m.chat.username else strings("id_none"),
chat_id=m.chat.id,
chat_dc=m.chat.dc_id or strings("unknown"),
chat_dc=m.chat.dc_id or strings("id_unknown"),
chat_type=m.chat.type,
message_id=m.id + 1,
)
Expand Down
2 changes: 1 addition & 1 deletion eduu/plugins/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def user_info(c: Client, m: Message, strings):
int(m.command[1]) if m.command[1].isdecimal() else m.command[1]
)
except BadRequest:
await m.reply_text(strings("user_not_found").format(user=m.command[1]))
await m.reply_text(strings("info_user_not_found").format(user=m.command[1]))
return

elif m.reply_to_message:
Expand Down
12 changes: 7 additions & 5 deletions eduu/plugins/inline_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ async def inline_search(c: Client, q: InlineQuery, strings):
await q.answer(
[
InlineQueryResultArticle(
title=strings("no_results").format(query=command),
title=strings("inline_cmds_no_results").format(query=command),
input_message_content=InputTextMessageContent(
strings("no_results").format(query=command)
strings("inline_cmds_no_results").format(query=command)
),
)
],
Expand All @@ -41,14 +41,16 @@ async def inline_search(c: Client, q: InlineQuery, strings):
InlineQueryResultArticle(
id=uuid4(),
title=result["command"],
description=strings(result["description_key"], context=result["context"]),
description=strings(result["description_key"]),
input_message_content=InputTextMessageContent(
f"{html.escape(result['command'])}: {strings(result['description_key'], context=result['context'])}"
f"{html.escape(result['command'])}: {strings(result['description_key'])}"
),
reply_markup=InlineKeyboardMarkup([
[
InlineKeyboardButton(
text=strings("run_command_button").format(query=stripped_command),
text=strings("inline_cmds_run_command_button").format(
query=stripped_command
),
switch_inline_query_current_chat=stripped_command,
)
]
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/inlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ async def info_inline(c: Client, q: InlineQuery, strings):
except (PeerIdInvalid, UsernameInvalid, UserIdInvalid):
await q.answer([
InlineQueryResultArticle(
title=strings("user_info_inline_cant_found_user"),
title=strings("user_info_inline_couldnt_find_user"),
input_message_content=InputTextMessageContent(
strings("user_info_inline_cant_found_user")
strings("user_info_inline_couldnt_find_user")
),
)
])
Expand Down
2 changes: 1 addition & 1 deletion eduu/plugins/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def ip_inline(c: Client, q: InlineQuery, strings):

articles = [
InlineQueryResultArticle(
title=strings("api_err_bogon_ip_inline").format(ip=ips[0])
title=strings("ip_inline_err_bogon_ip").format(ip=ips[0])
if api_return.get("bogon")
else strings("ip_info_inline").format(domain=text),
input_message_content=InputTextMessageContent(
Expand Down
Loading

0 comments on commit cd2dd7a

Please sign in to comment.