mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
pass locale details to backend
This commit is contained in:
parent
fe874e9909
commit
7d68da2b57
2 changed files with 8 additions and 1 deletions
|
@ -111,6 +111,7 @@ threadLocal = threading.local()
|
|||
# global defaults
|
||||
currentLang: Any = None
|
||||
currentTranslation: Any = None
|
||||
locale_folder: str = ""
|
||||
|
||||
|
||||
def localTranslation() -> Any:
|
||||
|
@ -135,10 +136,12 @@ def setLang(lang: str, locale_dir: str, local: bool = True) -> None:
|
|||
if local:
|
||||
threadLocal.currentLang = lang
|
||||
threadLocal.currentTranslation = trans
|
||||
threadLocal.locale_folder = locale_dir
|
||||
else:
|
||||
global currentLang, currentTranslation
|
||||
global currentLang, currentTranslation, locale_folder
|
||||
currentLang = lang
|
||||
currentTranslation = trans
|
||||
locale_folder = locale_dir
|
||||
|
||||
|
||||
def getLang() -> str:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# pylint: skip-file
|
||||
|
||||
import enum
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Dict, List, NewType, NoReturn, Optional, Tuple, Union
|
||||
|
||||
|
@ -179,10 +180,13 @@ def proto_progress_to_native(progress: pb.Progress) -> Progress:
|
|||
|
||||
class RustBackend:
|
||||
def __init__(self, col_path: str, media_folder_path: str, media_db_path: str):
|
||||
ftl_folder = os.path.join(anki.lang.locale_folder, "ftl")
|
||||
init_msg = pb.BackendInit(
|
||||
collection_path=col_path,
|
||||
media_folder_path=media_folder_path,
|
||||
media_db_path=media_db_path,
|
||||
locale_folder_path=ftl_folder,
|
||||
preferred_langs=[anki.lang.currentLang],
|
||||
)
|
||||
self._backend = ankirspy.open_backend(init_msg.SerializeToString())
|
||||
self._backend.set_progress_callback(self._on_progress)
|
||||
|
|
Loading…
Reference in a new issue