Skip to content

Commit 61e4733

Browse files
committed
Merge branch 'master' into v2
2 parents 635f4eb + 1a60301 commit 61e4733

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

README.md

-7
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ Install [GUI](https://github.com/argosopentech/argos-translate-gui):
2525
pip install argostranslategui
2626
```
2727

28-
### Installation for macOS
29-
30-
1. Download the latest [macOS release.](https://github.com/argosopentech/argos-translate/releases/)
31-
2. Extract the archive.
32-
3. Copy the `.app` file to the Applications directory.
33-
3428
### Python source installation into virtualenv
3529

3630
Download a copy of this repo and install with pip.
@@ -112,7 +106,6 @@ The GUI code is in a [separate repository](https://github.com/argosopentech/argo
112106

113107
![Screenshot](/img/Screenshot.png)
114108
![Screenshot2](/img/Screenshot2.png)
115-
![Argos Translate macOS Screenshot](/img/ArgosTranslateMacOSScreenshot.png)
116109

117110

118111
## [Packages](https://www.argosopentech.com/argospm/index/)

argostranslate/apply_bpe.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@ def isolate_glossary(word, glossary):
413413

414414

415415
if __name__ == "__main__":
416+
416417
currentdir = os.path.dirname(
417-
os.path.abspath(inspect.getfile(inspect.currentframe())) # type: ignore
418+
os.path.abspath(inspect.getfile(inspect.currentframe()))
418419
)
419420
newdir = os.path.join(currentdir, "subword_nmt")
420421
if os.path.isdir(newdir):

argostranslate/package.py

+24
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,27 @@ def uninstall(pkg):
394394
with package_lock:
395395
info("Uninstalled package", pkg)
396396
shutil.rmtree(pkg.package_path)
397+
398+
def install_package_for_language_pair(from_code: str, to_code: str) -> bool:
399+
"""Installs the necessary package to translate between a pair of languages
400+
Args:
401+
from_code (str): The ISO 639 code for the language being translated from
402+
to_code (str): The ISO 639 code for the language being translated to
403+
Returns:
404+
True if the package was installed successfully,
405+
False if the installation failed or was not possible
406+
"""
407+
available_packages = get_available_packages()
408+
try:
409+
package_to_install = next(
410+
filter(
411+
lambda x: x.from_code == from_code and x.to_code == to_code,
412+
available_packages,
413+
)
414+
)
415+
except StopIteration:
416+
return False
417+
418+
install_from_path(package_to_install.download())
419+
return True
420+

argostranslate/utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
std_out_stream_handler = logging.StreamHandler(sys.stdout)
1313
logger.addHandler(std_out_stream_handler)
1414

15+
# Python Logging Levels:
16+
# https://docs.python.org/3/library/logging.html#levels
17+
18+
19+
def debug(*argv):
20+
"""Debug level log"""
21+
logger.debug(str(argv))
22+
1523

1624
def get_json_string(argv):
1725
if len(argv) == 1:

0 commit comments

Comments
 (0)