Skip to main content

CLI application for learning Chinese.

Project description

laoshi (老師)

CLI application for learning Chinese. I wanted to have an interactive experience while I use the terminal, so I made this app.

Installation

pipx install laoshi

If you want to manage your AnkiDecks with laoshi, you'll need:

This allows us to make HTTP calls to your Anki application, you're going to need to have Anki open.

Usage

  cli application to learn chinese.

Options:
  --help  Show this message and exit.

Commands:
  cc           Convert characters
  manage-deck  Manage deck group
  translate    Translate a phrase 

You're able to convert characters, manage an Anki deck or translate a phrase.

Usage: laoshi cc [OPTIONS] WORD

  Convert characters

Options:
  -t, --to [traditional|simplified|pinyin]

The manage-deck subcommand allows you to create a deck from one seed word or phrase using create-deck, you can also add notes with add-note:

Usage: laoshi manage-deck [OPTIONS] COMMAND [ARGS]...

  Manage deck group

Options:
  --help  Show this message and exit.

Commands:
  add-note     add note function for click
  create-deck  Create a deck function for click

Lastly you can translate phrases or words with translate, by default we use english, but you can change that:

Usage: laoshi translate [OPTIONS] PHRASE

  Translate a phrase

Options:
  -t, --to TEXT
  --help         Show this message and exit.

Examples:

➜  ~ laoshi translate 服饰  
apparel
➜  ~ laoshi cc -t pinyin 服饰
fúshì
➜  ~ python -m laoshi.main manage-deck add-note -c simplified hsk5+ 涉及 # You have to create the AnkiDeck first.

Batch Import from JSON

You can import multiple flashcards at once using a JSON file.

laoshi manage-deck add-notes-from-json <deck_name> <path_to_json_file>

The JSON file should look like this:

[
  {
    "id": 1,
    "traditional_chinese": "你好",
    "pinyin": "nǐ hǎo",
    "part_of_speech": "phrase",
    "english_definition": "Hello",
    "example_sentences": [
      "你好吗?",
      "你好!"
    ]
  }
]

Local Development

To set up the project locally for development:

  1. Clone the repository:

    git clone https://gitlab.com/rbnjs/laoshi.git
    cd laoshi
    
  2. Install dependencies using uv (recommended) or pip:

    # using uv
    uv sync
    
    # or using pip
    pip install .
    pip install -r requirements-dev.txt # if available, or just install dev deps manually
    
  3. Run the application locally:

    # using uv
    uv run python -m laoshi.main --help
    
    # using standard python (after activating venv)
    python -m laoshi.main --help
    

Deployment

Deployment to PyPI is automated via GitLab CI/CD.

To trigger a deployment:

  1. Update the version in pyproject.toml.
  2. Push the changes to the master branch.
  3. The CI pipeline will automatically build and publish the package to PyPI using uv.

Ensure you have the necessary PyPI credentials configured in the GitLab CI/CD variables.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

laoshi-0.6.4.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laoshi-0.6.4-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file laoshi-0.6.4.tar.gz.

File metadata

  • Download URL: laoshi-0.6.4.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.31

File hashes

Hashes for laoshi-0.6.4.tar.gz
Algorithm Hash digest
SHA256 a9a9b1c1062c1da1ea24c0aba80fecde5e6dd2e78edb6a76fbf6e5c7c3b6c644
MD5 a52f4e9f05f675a336c195d04db7e2e8
BLAKE2b-256 495d95e316319481479f619baca7586d8a1f89b99629ed0363f6ef156e0ca8e0

See more details on using hashes here.

File details

Details for the file laoshi-0.6.4-py3-none-any.whl.

File metadata

  • Download URL: laoshi-0.6.4-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.31

File hashes

Hashes for laoshi-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8593d303a3f5adb33dc62e893e933acfd5bd123dd52f1385927fb2eef69102fd
MD5 1ec37c7ee65d9a459faf0e5935a8b551
BLAKE2b-256 709a21447d0e2e5f6d03ecdfe939754beeffa1cd4222300711ea5b6db0f70df7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page