commit 92bce92ead32e12934a439eff744f021a7d2c680 Author: Vaydheesh Date: Mon Apr 1 21:23:55 2019 +0530 Update the location of Language files for Windows Environment by checking at default installation path diff --git a/apertium/__init__.py b/apertium/__init__.py index 66ac4c2..3e0caa5 100644 --- a/apertium/__init__.py +++ b/apertium/__init__.py @@ -2,6 +2,10 @@ from apertium.mode_search import search_path from apertium.analysis import Analyzer, analyze # noqa: F401 from apertium.generation import Generator, generate # noqa: F401 from apertium.translation import Translator, translate # noqa: F401 +from platform import system +from os import getenv +from os.path import join +from os.path import isdir if False: @@ -38,9 +42,19 @@ def append_pair_path(pair_path): # type: (str) -> None _update_modes(pair_path) +def append_pair_path_windows(): + if system() == 'Windows': + install_path = getenv('LOCALAPPDATA') + apertium_lang_path = \ + join(install_path, 'apertium-all-dev', 'share', 'apertium') + if isdir(apertium_lang_path): + append_pair_path(apertium_lang_path) + + pair_paths = ['/usr/share/apertium', '/usr/local/share/apertium'] analyzers = {} # type: Dict[str, Tuple[str, str]] generators = {} # type: Dict[str, Tuple[str, str]] pairs = {} # type: Dict[str, str] for pair_path in pair_paths: _update_modes(pair_path) +append_pair_path_windows()