[i18n] Pass over economy, filter, general, image, mod

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
Toby Harradine
2018-10-05 15:07:56 +10:00
parent 0c3d8af8f4
commit fa692ccc0b
15 changed files with 720 additions and 640 deletions

View File

@@ -1,6 +1,6 @@
import datetime
import os
from typing import Union, List
from typing import Union, List, Optional
import discord
@@ -296,12 +296,20 @@ async def transfer_credits(from_: discord.Member, to: discord.Member, amount: in
return await deposit_credits(to, amount)
async def wipe_bank():
"""Delete all accounts from the bank."""
async def wipe_bank(guild: Optional[discord.Guild] = None) -> None:
"""Delete all accounts from the bank.
Parameters
----------
guild : discord.Guild
The guild to clear accounts for. If unsupplied and the bank is
per-server, all accounts in every guild will be wiped.
"""
if await is_global():
await _conf.clear_all_users()
else:
await _conf.clear_all_members()
await _conf.clear_all_members(guild)
async def get_leaderboard(positions: int = None, guild: discord.Guild = None) -> List[tuple]:

View File

@@ -838,7 +838,7 @@ class Config:
"""
return self._get_base_group(self.ROLE, role.id)
def user(self, user: discord.User) -> Group:
def user(self, user: discord.abc.User) -> Group:
"""Returns a `Group` for the given user.
Parameters

View File

@@ -1,5 +1,7 @@
import os
import re
from pathlib import Path
from typing import Callable, Union
from . import commands
@@ -113,9 +115,9 @@ def _normalize(string, remove_newline=False):
ends_with_space = s[-1] in " \n\t\r"
if remove_newline:
newline_re = re.compile("[\r\n]+")
s = " ".join(filter(bool, newline_re.split(s)))
s = " ".join(filter(bool, s.split("\t")))
s = " ".join(filter(bool, s.split(" ")))
s = " ".join(filter(None, newline_re.split(s)))
s = " ".join(filter(None, s.split("\t")))
s = " ".join(filter(None, s.split(" ")))
if starts_with_space:
s = " " + s
if ends_with_space:
@@ -149,10 +151,10 @@ def get_locale_path(cog_folder: Path, extension: str) -> Path:
return cog_folder / "locales" / "{}.{}".format(get_locale(), extension)
class Translator:
class Translator(Callable[[str], str]):
"""Function to get translated strings at runtime."""
def __init__(self, name, file_location):
def __init__(self, name: str, file_location: Union[str, Path, os.PathLike]):
"""
Initializes an internationalization object.
@@ -173,7 +175,7 @@ class Translator:
self.load_translations()
def __call__(self, untranslated: str):
def __call__(self, untranslated: str) -> str:
"""Translate the given string.
This will look for the string in the translator's :code:`.pot` file,