Skip to content

Commit

Permalink
v0.3.1b5
Browse files Browse the repository at this point in the history
  • Loading branch information
wasertech committed Mar 13, 2023
1 parent 40b79f0 commit bcaab9b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 11 deletions.
70 changes: 63 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,26 @@ Uses Meta's NLLB model [`facebook/nllb-200-distilled-600M`](https://huggingface.

## Installation

Use `pip` to install Translator (only from source for now).
Use `pip` to install Translator.

```zsh
pip install git+https://github.com/wasertech/Translator.git
which translate
❯ pip install interpres
```

Or from source.
```zsh
❯ pip install git+https://github.com/wasertech/Translator.git
```

You can also use a specific version.
```zsh
❯ pip install interpres==0.3.1b4
❯ pip install git+https://github.com/wasertech/[email protected]
```

Locate Translator.
```zsh
❯ which translate
```

## Usage
Expand Down Expand Up @@ -73,14 +88,55 @@ options:

You can `translate` `from` one language `to` another, any `sentence` you would like.

```zsh
# Translate from English in French
Greet Translator.
```
❯ translate
ℹ Welcome!
ℹ I am Translator.
ℹ Translator version: 0.3.1b4
ℹ At your service.
? What would you like to translate? Manually typed sentences
ℹ Translating from: Manually typed sentences
? What language to translate from? en
ℹ Translating from eng_Latn.
? What language to translate to? fr
ℹ Translating to fra_Latn.
ℹ Preparing to translate...
Type [Ctrl] + [C] to exit.
What would you like to translate?
? Translate: This is a prompt-like translation shell!
C'est une coquille de traduction rapide !
What would you like to translate?
? Translate: You can quickly and effortlessly translate anything from here!
Vous pouvez traduire n'importe quoi rapidement et sans effort.
What would you like to translate?
? Translate: I hope you like my work and are considering becoming a sponsor...
J'espère que vous aimez mon travail et que vous envisagez devenir sponsor...
What would you like to translate?
? Translate:
Cancelled by user
```

Translate from English in French.
```
❯ translate eng_Latn fra_Latn "This is French."
C\'est français.
C'est français.
# Translate from English in Spanish
❯ LANG="fr_CH.UTF-8" translate en "This is also French."
C'est aussi du français.
```

Translate from English in Spanish.
```zsh
❯ translate eng_Latn spa_Latn "This is Spanish."
Esto es español.

❯ translate en es "This is also Spanish."
Esto también es español.
```

You can also easily `translate` files from a `--directory` and `--save` to a file.
Expand Down
2 changes: 1 addition & 1 deletion translator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from translator.translate import Translator
from translator.language import get_nllb_lang

__version__ = "0.3.1b4"
__version__ = "0.3.1b5"

LANGS = get_nllb_lang()
7 changes: 4 additions & 3 deletions translator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def _log(msg, logger=None, spinner=None, _type="info"):
print(msg)
return msg

def print_version(version, _to=get_sys_lang_format(), is_interactive=False, spinner=None, logger=None, max_length=max_translation_lenght, model_id=default_translator_model, pipeline=default_translator_pipeline):
_version = "Translator version:"
def print_version(version, prefix="Translator version:", _to=get_sys_lang_format(), is_interactive=False, spinner=None, logger=None, max_length=max_translation_lenght, model_id=default_translator_model, pipeline=default_translator_pipeline):
_version = prefix
_lang = "eng_Latn"
v = None

Expand Down Expand Up @@ -183,7 +183,7 @@ def main():
if not _from and not _to and not _sentences and not _directory and is_interactive:
_log("Welcome!", logger, spinner, 'info')
_log("I am Translator.", logger, spinner, 'info')
print_version(__version__, _to="".join(args._to) or 'eng_Latn', is_interactive=is_interactive, spinner=spinner, logger=logger, max_length=args.max_length, model_id=args.model_id, pipeline=args.pipeline)
print_version(__version__, prefix="I am Translator version:", _to="".join(args._to) or 'eng_Latn', is_interactive=is_interactive, spinner=spinner, logger=logger, max_length=args.max_length, model_id=args.model_id, pipeline=args.pipeline)
_log("At your service.", logger, spinner, 'info')

options = ["Manually typed sentences", "Stored sentences in file(s)", "Nothing, just exit"]
Expand Down Expand Up @@ -243,6 +243,7 @@ def main():
raise exception

_log("Type [Ctrl] + [C] to exit.")
_log(" "*10)
try:
while True:
_log("What would you like to translate?")
Expand Down

0 comments on commit bcaab9b

Please sign in to comment.