#' Print methods
#'
#' Print methods for objects generated by the transdoc package.
#' Browser opens Google Translate to translate the input documents.
#'
#' @inheritParams translate
#' @inheritParams base::print
#'
#' @examples
#' if (interactive()) {
#' print(translate("This text will be translated to Japanese", "ja"))
#' print(translate("https://transdoc.atusy.net/", "ja"))
#' print(translate(?base::c, "ja"))
#' }
#'
#' @return The input `x`.
#'
#' @name print-methods
#' @export
print.transdoc_help <- function(x, to = "default", ...) {
if (check_offline(msg = "Being offline.", action = warning)) {
class(x) <- "help_files_with_topic"
print(x)
} else {
print.transdoc_website(translate(x, to = to, ...))
}
}
#' @export
print.transdoc_website <- function(x, ...) {
check_offline()
x$to <- transdoc_to(x$to)
utils::browseURL(url_google_translate(x$to, x$topic, type = "website"))
invisible(x)
}
#' @export
print.transdoc_text <- function(x, ...) {
check_offline()
x$to <- transdoc_to(x$to)
utils::browseURL(url_google_translate(x$to, x$topic, type = "text"))
invisible(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.