Package 'deepRstudio'

Title: Seamless Language Translation in 'RStudio' using 'DeepL' API and 'Rstudioapi'
Description: Enhancing cross-language compatibility within the 'RStudio' environment and supporting seamless language understanding, the 'deepRstudio' package leverages the power of the 'DeepL' API (see <https://www.deepl.com/docs-api>) to enable seamless, fast, accurate, and affordable translation of code comments, documents, and text. This package offers the ability to translate selected text into English (EN), as well as from English into various languages, namely Japanese (JA), Chinese (ZH), Spanish (ES), French (FR), Russian (RU), Portuguese (PT), and Indonesian (ID). With much of the text being written in English, the emphasis is on compatibility from English. It is also designed for developers working on multilingual projects and data analysts collaborating with international teams, simplifying the translation process and making code more accessible and comprehensible to people with diverse language backgrounds. This package uses the 'rstudioapi' package and 'DeepL' API, and is simply implemented, executed from addins or via shortcuts on 'RStudio'. With just a few steps, content can be translated between supported languages, promoting better collaboration and expanding the global reach of work. The functionality of this package works only on 'RStudio' using 'rstudioapi'.
Authors: Satoshi Kume [aut, cre]
Maintainer: Satoshi Kume <[email protected]>
License: Artistic-2.0
Version: 0.0.9
Built: 2024-08-31 05:06:02 UTC
Source: https://github.com/kumes/deeprstudio

Help Index


DeepL Translation Function

Description

This function translates text using the DeepL API.

Usage

deepel(
  input,
  target_lang = "EN",
  Auth_Key = Sys.getenv("DeepL_API_KEY"),
  free_mode = TRUE
)

Arguments

input

The text to be translated.

target_lang

The target language code for translation. The language into which the text should be translated. Options are: BG - Bulgarian, CS - Czech, DA - Danish, DE - German, EL - Greek, EN - English (unspecified variant for backward compatibility; please select EN-GB or EN-US instead), EN-GB - English (British), EN-US - English (American), ES - Spanish, ET - Estonian, FI - Finnish, FR - French, HU - Hungarian, ID - Indonesian, IT - Italian, JA - Japanese, KO - Korean, LT - Lithuanian, LV - Latvian, NB - Norwegian (Bokmål), NL - Dutch, PL - Polish, PT - Portuguese (unspecified variant for backward compatibility; please select PT-BR or PT-PT instead), PT-BR - Portuguese (Brazilian), PT-PT - Portuguese (all Portuguese varieties excluding Brazilian Portuguese), RO - Romanian, RU - Russian, SK - Slovak, SL - Slovenian, SV - Swedish, TR - Turkish, UK - Ukrainian, ZH - Chinese (simplified).

Auth_Key

Your DeepL API authentication key. Defaults to the value of the environment variable "DeepL_API_KEY".

free_mode

A boolean value; set to TRUE if using the free DeepL API, FALSE if using the paid version. Default is TRUE.

Value

A data frame containing the detected source language, target language, and translated text.

Author(s)

Satoshi Kume

Examples

## Not run: 
Auth_Key <- "your_deepl_api_key"
input <- "Hello, how are you?"
target_lang <- "JA"

translated_text <- deepel(input, target_lang, Auth_Key)
print(translated_text)

## End(Not run)

Translate English Text to Other Languages via DeepL API

Description

Translate English text from the clipboard into the specified target language using the DeepL API.

Usage

deepel_from_EN(
  target_lang = "JA",
  Auth_Key = Sys.getenv("DeepL_API_KEY"),
  free_mode = TRUE
)

Arguments

target_lang

The language into which the text should be translated. Options are: BG - Bulgarian, CS - Czech, DA - Danish, DE - German, EL - Greek, EN - English (unspecified variant for backward compatibility; please select EN-GB or EN-US instead), EN-GB - English (British), EN-US - English (American), ES - Spanish, ET - Estonian, FI - Finnish, FR - French, HU - Hungarian, ID - Indonesian, IT - Italian, JA - Japanese, KO - Korean, LT - Lithuanian, LV - Latvian, NB - Norwegian (Bokmål), NL - Dutch, PL - Polish, PT - Portuguese (unspecified variant for backward compatibility; please select PT-BR or PT-PT instead), PT-BR - Portuguese (Brazilian), PT-PT - Portuguese (all Portuguese varieties excluding Brazilian Portuguese), RO - Romanian, RU - Russian, SK - Slovak, SL - Slovenian, SV - Swedish, TR - Turkish, UK - Ukrainian, ZH - Chinese (simplified). assertthat::is.string(target_lang)

Auth_Key

The authentication key for the DeepL API.

free_mode

A logical value indicating whether to use the free or paid DeepL API. Default is TRUE.

Details

Translate English Text to Other Languages via DeepL API

This function takes English text from the clipboard and translates it into the specified target language using the DeepL API. The translated text is then placed back into the clipboard, ready to be pasted wherever needed.

Value

The translated text is placed into the clipboard and the function returns the result of clipr::write_clip.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Copy English text into your clipboard to excute the function. Then paste your clipboard.
deepel_from_EN(target_lang = 'JA')


## End(Not run)

Translate Selected Text to English via DeepL API

Description

Translate the selected text in RStudio into English using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2EN()

Details

Translate Selected Text to English via DeepL API

This function uses the rstudioapi to execute English translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into English. First, select the text and execute "DeepL Translation into English" from addins. As a result, the selected part will be translated into English.

Value

No value is returned.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into English" from RStudio addins.


## End(Not run)

Translate Selected Text to Spanish via DeepL API

Description

Translate the selected text in RStudio into Spanish using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2ES()

Details

Translate Selected Text to Spanish via DeepL API

This function uses the rstudioapi to execute Spanish translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Spanish. First, select the text and execute "DeepL Translation into Spanish" from addins. As a result, the selected part will be translated into Spanish.

Value

A message indicating the completion of the translation. No value is returned.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Spanish" from RStudio addins.


## End(Not run)

Translate Selected Text to French via DeepL API

Description

Translate the selected text in RStudio into French using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2FR()

Details

Translate Selected Text to French via DeepL API

This function uses the rstudioapi to execute French translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into French. First, select the text and execute "DeepL Translation into French" from addins. As a result, the selected part will be translated into French.

Value

A message indicating the completion of the translation. No value is returned.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into French" from RStudio addins.


## End(Not run)

Translate Selected Text to Indonesian via DeepL API

Description

Translate the selected text in RStudio into Indonesian using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2ID()

Details

Translate Selected Text to Indonesian via DeepL API

This function uses the rstudioapi to execute Indonesian translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Indonesian. First, select the text and execute "DeepL Translation into Indonesian" from addins. As a result, the selected part will be translated into Indonesian.

Value

A message indicating the completion of the translation. No value is returned.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Indonesian" from RStudio addins.


## End(Not run)

Translate Selected Text to Japanese via DeepL API

Description

Translate the selected text in RStudio into Japanese using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2JA()

Details

Translate Selected Text to Japanese via DeepL API

This function uses the rstudioapi to execute Japanese translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Japanese. First, select the text and execute "DeepL Translation into Japanese" from addins. As a result, the selected part will be translated into Japanese.

Value

A message indicating the completion of the translation. No value is returned.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Japanese" from RStudio addins.


## End(Not run)

Translate Selected Text to Portuguese via DeepL API

Description

Translate the selected text in RStudio into Portuguese using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2PT()

Details

Translate Selected Text to Portuguese via DeepL API

This function uses the rstudioapi to execute Portuguese translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Portuguese. First, select the text and execute "DeepL Translation into Portuguese" from addins. As a result, the selected part will be translated into Portuguese.

Value

A message indicating the completion of the translation.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Portuguese" from RStudio addins.


## End(Not run)

Translate Selected Text to Russian via DeepL API

Description

Translate the selected text in RStudio into Russian using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2RU()

Details

Translate Selected Text to Russian via DeepL API

This function uses the rstudioapi to execute Russian translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Russian. First, select the text and execute "DeepL Translation into Russian" from addins. As a result, the selected part will be translated into Russian.

Value

A message indicating the completion of the translation.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Russian" from RStudio addins.


## End(Not run)

Translate Selected Text to Chinese via DeepL API

Description

Translate the selected text in RStudio into Chinese using the DeepL API with auto-detection of the source language. This function uses free-version DeepL API (https://api-free.deepl.com/v2/translate).

Usage

deepel_rstudioapi_2ZH()

Details

Translate Selected Text to Chinese via DeepL API

This function uses the rstudioapi to execute Chinese translation of the selected text using the DeepL API. It will attempt to auto-detect the language of the text and translate it into Chinese. First, select the text and execute "DeepL Translation into Chinese" from addins. As a result, the selected part will be translated into Chinese.

Value

A message indicating the completion of the translation.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Select the following text: "La selección está traducida al inglés."
#Then, execute "DeepL Translation into Chinese" from RStudio addins.


## End(Not run)

Translate and Speak in Japanese

Description

This function takes the selected text in RStudio, translates it into Japanese using the DeepL API, and then speaks the translated text using MacOS's speech system.

Usage

deepel_rstudioapi_speakInJA()

Details

Translate Selected Text and Speak in Japanese via DeepL API and MacOS system

Value

A message indicating that the translation and speech process has finished.

Author(s)

Satoshi Kume

Examples

## Not run: 
#Select the following text: "La selección está traducida al inglés."
#Then, execute "Translation and Speak in Japanese : deepRstudio" from RStudio addins.

## End(Not run)

Translate X Language to Other X Language via DeepL API

Description

Translate English text from the clipboard into the specified target language using the DeepL API.

Usage

deepel_X2X(
  target_lang = "JA",
  Auth_Key = Sys.getenv("DeepL_API_KEY"),
  free_mode = TRUE
)

Arguments

target_lang

The language into which the text should be translated. Options are: BG - Bulgarian, CS - Czech, DA - Danish, DE - German, EL - Greek, EN - English (unspecified variant for backward compatibility; please select EN-GB or EN-US instead), EN-GB - English (British), EN-US - English (American), ES - Spanish, ET - Estonian, FI - Finnish, FR - French, HU - Hungarian, ID - Indonesian, IT - Italian, JA - Japanese, KO - Korean, LT - Lithuanian, LV - Latvian, NB - Norwegian (Bokmål), NL - Dutch, PL - Polish, PT - Portuguese (unspecified variant for backward compatibility; please select PT-BR or PT-PT instead), PT-BR - Portuguese (Brazilian), PT-PT - Portuguese (all Portuguese varieties excluding Brazilian Portuguese), RO - Romanian, RU - Russian, SK - Slovak, SL - Slovenian, SV - Swedish, TR - Turkish, UK - Ukrainian, ZH - Chinese (simplified). assertthat::is.string(target_lang)

Auth_Key

The authentication key for the DeepL API.

free_mode

A logical value indicating whether to use the free or paid DeepL API. Default is TRUE.

Details

Translate X to X via DeepL API

This function takes text from the clipboard and translates it into the specified target language using the DeepL API. The translated text is then placed back into the clipboard, ready to be pasted wherever needed.

Value

The translated text is placed into the clipboard and the function returns the result of clipr::write_clip.

Author(s)

Satoshi Kume

Examples

## Not run: 

#Copy text into your clipboard to excute the function. Then paste your clipboard.
deepel_X2X(target_lang = 'JA')


## End(Not run)

Check Mac OS (Darwin)

Description

Determines if the current system is running on Mac OS (Darwin).

Usage

is_mac()

Details

Check if the System is Running on Mac OS

This function determines whether the current system is running on Mac OS. It utilizes the system information provided by R to check the operating system name, and returns TRUE if it is Mac OS (Darwin), and FALSE otherwise.

Value

Logical value indicating whether the system is Mac OS. Returns TRUE if Mac OS, FALSE otherwise.

Author(s)

Satoshi Kume

Examples

## Not run: 
if (is_mac()) {
  print("This is a Mac OS system.")
} else {
  print("This is not a Mac OS system.")
}

## End(Not run)

Slowly Print Text

Description

Prints the characters of the input text string one by one, with a specified delay between each character. If the random parameter is set to TRUE, the delay will be a random value between 0.0001 and 0.3 seconds. Otherwise, the delay will be the value specified by the delay parameter.

Usage

slow_print(text, random = FALSE, delay = 0.125)

Arguments

text

A string representing the text to be printed. Must be a non-NA string.

random

A logical value indicating whether the delay between characters should be random. Default is FALSE.

delay

A numeric value representing the fixed delay between characters in seconds. Default is 0.125. Must be a non-negative number.

Details

Slowly Print Text

This function prints the characters of a given text string one by one, with a specified delay between each character. The delay can be either fixed or random.

Value

Invisible NULL. The function prints the text to the console.

Author(s)

Satoshi Kume

Examples

## Not run: 
slow_print("Hello, World!")
slow_print("Hello, World!", random = TRUE)
slow_print("Hello, World!", delay = 0.1)

## End(Not run)