mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 09:16:38 -04:00
Merge upstream/main into fix/progress-overflow-4341
This commit is contained in:
commit
3025a6f24d
7 changed files with 68 additions and 11 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -46,9 +46,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ammonia"
|
name = "ammonia"
|
||||||
version = "4.1.1"
|
version = "4.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6b346764dd0814805de8abf899fe03065bcee69bb1a4771c785817e39f3978f"
|
checksum = "17e913097e1a2124b46746c980134e8c954bc17a6a59bb3fde96f088d126dde6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"html5ever 0.35.0",
|
"html5ever 0.35.0",
|
||||||
|
|
|
@ -51,7 +51,7 @@ ninja_gen = { "path" = "build/ninja_gen" }
|
||||||
unicase = "=2.6.0" # any changes could invalidate sqlite indexes
|
unicase = "=2.6.0" # any changes could invalidate sqlite indexes
|
||||||
|
|
||||||
# normal
|
# normal
|
||||||
ammonia = "4.1.0"
|
ammonia = "4.1.2"
|
||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
async-compression = { version = "0.4.24", features = ["zstd", "tokio"] }
|
async-compression = { version = "0.4.24", features = ["zstd", "tokio"] }
|
||||||
async-stream = "0.3.6"
|
async-stream = "0.3.6"
|
||||||
|
|
|
@ -18,7 +18,7 @@ from anki._legacy import DeprecatedNamesMixinForModule
|
||||||
TR = anki._fluent.LegacyTranslationEnum
|
TR = anki._fluent.LegacyTranslationEnum
|
||||||
FormatTimeSpan = _pb.FormatTimespanRequest
|
FormatTimeSpan = _pb.FormatTimespanRequest
|
||||||
|
|
||||||
|
# When adding new languages here, check lang_to_disk_lang() below
|
||||||
langs = sorted(
|
langs = sorted(
|
||||||
[
|
[
|
||||||
("Afrikaans", "af_ZA"),
|
("Afrikaans", "af_ZA"),
|
||||||
|
@ -38,6 +38,7 @@ langs = sorted(
|
||||||
("Italiano", "it_IT"),
|
("Italiano", "it_IT"),
|
||||||
("lo jbobau", "jbo_EN"),
|
("lo jbobau", "jbo_EN"),
|
||||||
("Lenga d'òc", "oc_FR"),
|
("Lenga d'òc", "oc_FR"),
|
||||||
|
("Қазақша", "kk_KZ"),
|
||||||
("Magyar", "hu_HU"),
|
("Magyar", "hu_HU"),
|
||||||
("Nederlands", "nl_NL"),
|
("Nederlands", "nl_NL"),
|
||||||
("Norsk", "nb_NO"),
|
("Norsk", "nb_NO"),
|
||||||
|
@ -64,6 +65,7 @@ langs = sorted(
|
||||||
("Українська мова", "uk_UA"),
|
("Українська мова", "uk_UA"),
|
||||||
("Հայերեն", "hy_AM"),
|
("Հայերեն", "hy_AM"),
|
||||||
("עִבְרִית", "he_IL"),
|
("עִבְרִית", "he_IL"),
|
||||||
|
("ייִדיש", "yi"),
|
||||||
("العربية", "ar_SA"),
|
("العربية", "ar_SA"),
|
||||||
("فارسی", "fa_IR"),
|
("فارسی", "fa_IR"),
|
||||||
("ภาษาไทย", "th_TH"),
|
("ภาษาไทย", "th_TH"),
|
||||||
|
@ -104,6 +106,7 @@ compatMap = {
|
||||||
"it": "it_IT",
|
"it": "it_IT",
|
||||||
"ja": "ja_JP",
|
"ja": "ja_JP",
|
||||||
"jbo": "jbo_EN",
|
"jbo": "jbo_EN",
|
||||||
|
"kk": "kk_KZ",
|
||||||
"ko": "ko_KR",
|
"ko": "ko_KR",
|
||||||
"la": "la_LA",
|
"la": "la_LA",
|
||||||
"mn": "mn_MN",
|
"mn": "mn_MN",
|
||||||
|
@ -126,6 +129,7 @@ compatMap = {
|
||||||
"uk": "uk_UA",
|
"uk": "uk_UA",
|
||||||
"uz": "uz_UZ",
|
"uz": "uz_UZ",
|
||||||
"vi": "vi_VN",
|
"vi": "vi_VN",
|
||||||
|
"yi": "yi",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,7 +237,7 @@ def get_def_lang(user_lang: str | None = None) -> tuple[int, str]:
|
||||||
|
|
||||||
|
|
||||||
def is_rtl(lang: str) -> bool:
|
def is_rtl(lang: str) -> bool:
|
||||||
return lang in ("he", "ar", "fa", "ug")
|
return lang in ("he", "ar", "fa", "ug", "yi")
|
||||||
|
|
||||||
|
|
||||||
# strip off unicode isolation markers from a translated string
|
# strip off unicode isolation markers from a translated string
|
||||||
|
|
|
@ -226,6 +226,7 @@ def show(mw: aqt.AnkiQt) -> QDialog:
|
||||||
"Anon_0000",
|
"Anon_0000",
|
||||||
"Bilolbek Normuminov",
|
"Bilolbek Normuminov",
|
||||||
"Sagiv Marzini",
|
"Sagiv Marzini",
|
||||||
|
"Zhanibek Rassululy",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -170,13 +170,42 @@ def favicon() -> Response:
|
||||||
|
|
||||||
def _mime_for_path(path: str) -> str:
|
def _mime_for_path(path: str) -> str:
|
||||||
"Mime type for provided path/filename."
|
"Mime type for provided path/filename."
|
||||||
if path.endswith(".css"):
|
|
||||||
# some users may have invalid mime type in the Windows registry
|
_, ext = os.path.splitext(path)
|
||||||
return "text/css"
|
ext = ext.lower()
|
||||||
elif path.endswith(".js") or path.endswith(".mjs"):
|
|
||||||
return "application/javascript"
|
# Badly-behaved apps on Windows can alter the standard mime types in the registry, which can completely
|
||||||
|
# break Anki's UI. So we hard-code the most common extensions.
|
||||||
|
mime_types = {
|
||||||
|
".css": "text/css",
|
||||||
|
".js": "application/javascript",
|
||||||
|
".mjs": "application/javascript",
|
||||||
|
".html": "text/html",
|
||||||
|
".htm": "text/html",
|
||||||
|
".svg": "image/svg+xml",
|
||||||
|
".png": "image/png",
|
||||||
|
".jpg": "image/jpeg",
|
||||||
|
".jpeg": "image/jpeg",
|
||||||
|
".gif": "image/gif",
|
||||||
|
".webp": "image/webp",
|
||||||
|
".ico": "image/x-icon",
|
||||||
|
".json": "application/json",
|
||||||
|
".woff": "font/woff",
|
||||||
|
".woff2": "font/woff2",
|
||||||
|
".ttf": "font/ttf",
|
||||||
|
".otf": "font/otf",
|
||||||
|
".mp3": "audio/mpeg",
|
||||||
|
".mp4": "video/mp4",
|
||||||
|
".webm": "video/webm",
|
||||||
|
".ogg": "audio/ogg",
|
||||||
|
".pdf": "application/pdf",
|
||||||
|
".txt": "text/plain",
|
||||||
|
}
|
||||||
|
|
||||||
|
if mime := mime_types.get(ext):
|
||||||
|
return mime
|
||||||
else:
|
else:
|
||||||
# autodetect
|
# fallback to mimetypes, which may consult the registry
|
||||||
mime, _encoding = mimetypes.guess_type(path)
|
mime, _encoding = mimetypes.guess_type(path)
|
||||||
return mime or "application/octet-stream"
|
return mime or "application/octet-stream"
|
||||||
|
|
||||||
|
|
|
@ -134,5 +134,8 @@ pub fn ensure_os_supported() -> Result<()> {
|
||||||
#[cfg(all(unix, not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
unix::ensure_glibc_supported()?;
|
unix::ensure_glibc_supported()?;
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
windows::ensure_windows_version_supported()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,26 @@ fn is_windows_10() -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ensures Windows 10 version 1809 or later
|
||||||
|
pub fn ensure_windows_version_supported() -> Result<()> {
|
||||||
|
unsafe {
|
||||||
|
let mut info = OSVERSIONINFOW {
|
||||||
|
dwOSVersionInfoSize: std::mem::size_of::<OSVERSIONINFOW>() as u32,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
if RtlGetVersion(&mut info).is_err() {
|
||||||
|
anyhow::bail!("Failed to get Windows version information");
|
||||||
|
}
|
||||||
|
|
||||||
|
if info.dwBuildNumber >= 17763 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
anyhow::bail!("Windows 10 version 1809 or later is required.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn ensure_terminal_shown() -> Result<()> {
|
pub fn ensure_terminal_shown() -> Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !GetConsoleWindow().is_invalid() {
|
if !GetConsoleWindow().is_invalid() {
|
||||||
|
|
Loading…
Reference in a new issue