Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Improve and fix the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Jun 22, 2018
1 parent 5c8e744 commit f6ad01c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 44 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

[![GitHub (pre-)release](https://img.shields.io/github/release/Shatur95/QOnlineTranslator/all.svg)](https://github.com/Shatur95/QOnlineTranslator/releases)

The **QOnlineTranslator** library provides free usage of Google Translate API for **Qt5**. It uses the Google API URL to get the response, and then parse the reply. [Detailed documentation](docs/QOnlineTranslator.md "Class documentation").
**QOnlineTranslator** is a library for **Qt5** that provides free usage of Google Translate API. It uses the Google API URL to get the response, and then parse the reply. [Detailed documentation](docs/QOnlineTranslator.md "Class documentation").

Example:

```cpp
QCoreApplication a(argc, argv); // Always need to create app instance for QEventLoop
QTextStream out(stdout);
...
QOnlineTranslator onlineTranslator("hello");
qInfo() << onlineTranslator.translation(); // Returns "hello" translated to the language of your system
out << onlineTranslator.text; // Returns "hello" translated to the language of your system

onlineTranslator.translate("Hello world!", "de");
qInfo() << onlineTranslator.translation(); // Returns "Hello world!" translated into German
out << onlineTranslator.text; // Returns "Hello world!" translated into German
```
For real example of usage you can look into my other project: [Crow Translate](https://github.com/Shatur95/CrowTranslate "A simple and lightweight translator that allows to translate and say the selected text using the Google Translate API").
Expand All @@ -28,6 +30,8 @@ or this to clone with **https**:
`git submodule add https://github.com/Shatur95/QOnlineTranslator.git src/third-party/qonlinetranslator`
or if you don't want to add the library as a submodule, you can download the archive from the [releases](https://github.com/Shatur95/QOnlineTranslator/releases) page and unpack it to the desired folder **manually**.
Then include the `qonlinetranslator.pri` file in your `.pro` project file:
`include(src/third-party/qonlinetranslator/qonlinetranslator.pri)`
Expand Down
20 changes: 10 additions & 10 deletions docs/QDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ The **QDefinition** class provides storage for definitions data.

## Public Functions

| Return type | Data member |
|------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------|
| | [**QDefinition**(const QString &typeOfSpeech = "", const QString &description = "", const QString &example = "")](#c1) |
| QString | [**typeOfSpeech**()](#type-of-speech) |
| QString | [**description**()](#description) |
| QString | [**example**()](#example) |
| void | [**setTypeOfSpeech**(const QString &typeOfSpeech)](#set-type-of-speech) |
| void | [**setDescription**(const QString &description)](#set-description) |
| void | [**setExample**(const QString &example)](#set-example) |
| Return type | Data member |
|------------:|:-----------------------------------------------------------------------------------------------------------------------|
| | [**QDefinition**(const QString &typeOfSpeech = "", const QString &description = "", const QString &example = "")](#c1) |
| QString | [**typeOfSpeech**()](#type-of-speech) |
| QString | [**description**()](#description) |
| QString | [**example**()](#example) |
| void | [**setTypeOfSpeech**(const QString &typeOfSpeech)](#set-type-of-speech) |
| void | [**setDescription**(const QString &description)](#set-description) |
| void | [**setExample**(const QString &example)](#set-example) |

## Detailed Description

The **QDefinition** class provides storage for for definitions data.
The **QDefinition** object can be obtained from the [QOnlineTranslator](docs/QOnlineTranslator.md "Class documentation") object, which contains a list of definitions.

Example:

Expand Down
18 changes: 0 additions & 18 deletions docs/QOnlineTranslator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The **QOnlineTranslator** class provides translation data.

* [Public Functions](#public-functions)
* [Static Public Functions](#static-public-functions)
* [Detailed Description](#detailed-description)
* [Member Function Documentation](#member-function-documentation)

## Public Functions
Expand Down Expand Up @@ -40,23 +39,6 @@ The **QOnlineTranslator** class provides translation data.
| QString | [**translateText**(const QString &text, QString translationLanguage = "auto", QString sourceLanguage = "auto")](#translate-text-static) |
| QList<QMediaContent> | [**media**(const QString &text, QString language = "auto")](#media) |

## Detailed Description

The **QOnlineTranslator** uses the Google API URL to get the response, and then the parse the reply.

Example:
```cpp
QCoreApplication a(argc, argv); // Always need to create app instance for QEventLoop
...
QOnlineTranslator onlineTranslator("hello");
qInfo() << onlineTranslator.text; // Returns "hello" translated to the language of your system

onlineTranslator.translate("Hello world!", "de");
qInfo() << onlineTranslator.text; // Returns "Hello world!" translated into German
```
For real example of usage you can look into my other project: [Crow Translate](https://github.com/Shatur95/CrowTranslate "A simple and lightweight translator that allows to translate and say the selected text using the Google Translate API").
## Member Function Documentation

### <a id='c1'/> QOnlineTranslator::QOnlineTranslator(*QObject \*parent = nullptr*)
Expand Down
26 changes: 13 additions & 13 deletions docs/QTranslationOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ The **QTranslationOptions** class provides storage for translation options data

## Public Functions

| Return type | Data member |
|------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------|
| | [**QTranslationOptions**(const QString &typeOfSpeech = "")](#c1) |
| QString | [**typeOfSpeech**()](#type-of-speech) |
| QString | [**word**(int index)](#word) |
| QString | [**gender**(int index)](#gender) |
| QStringList | [**translations**(int index)](#translations) |
| void | [**setTypeOfSpeech**(const QString &typeOfSpeech)](#set-type-of-speech) |
| void | [**appendOption**(const QString &word, const QString &gender = "", const QStringList &translations = QStringList())](#append-option) |
| void | [**appendTranslation**(int index, const QString &translation)](#append-translation-1) |
| void | [**appendTranslation**(const QString &translation)](#append-translation-2) |
| int | [**count**()](#count) |
| Return type | Data member |
|------------:|:-------------------------------------------------------------------------------------------------------------------------------------|
| | [**QTranslationOptions**(const QString &typeOfSpeech = "")](#c1) |
| QString | [**typeOfSpeech**()](#type-of-speech) |
| QString | [**word**(int index)](#word) |
| QString | [**gender**(int index)](#gender) |
| QStringList | [**translations**(int index)](#translations) |
| void | [**setTypeOfSpeech**(const QString &typeOfSpeech)](#set-type-of-speech) |
| void | [**appendOption**(const QString &word, const QString &gender = "", const QStringList &translations = QStringList())](#append-option) |
| void | [**appendTranslation**(int index, const QString &translation)](#append-translation-1) |
| void | [**appendTranslation**(const QString &translation)](#append-translation-2) |
| int | [**count**()](#count) |

## Detailed Description

The **QTranslationOptions** class provides storage for translation options data for a single type of speech.
The **QTranslationOptions** object can be obtained from the [QOnlineTranslator](docs/QOnlineTranslator.md "Class documentation") object, which contains a list of translation options for a single type of speech.

Example:

Expand Down

0 comments on commit f6ad01c

Please sign in to comment.