Skip to content

Commit

Permalink
fix R-level fr-FR translation (#1176)
Browse files Browse the repository at this point in the history
* update FR .mo file

* apply P Grosjean advice

* fix R-torch message translations

* add fr-translation tests

* Delete duplicate test-translation.R

* Improve test name

* Update test-message-translations.R

* add NEWS

* Increment version number to 0.13.0.9000

* cleanup NEWS

* update FR .mo file

* apply P Grosjean advice

* fix R-torch message translations

* add fr-translation tests

* Delete duplicate test-translation.R

* Improve test name

* Update test-message-translations.R

* add NEWS

* Increment version number to 0.13.0.9000

* cleanup NEWS

* fix gettext return a list that must be flatten

* fix 2nd test to be a pure R-level test

* align with latest additions

* bypass cuda & mps

* can we revert 2d78c6b ?

* Revert "can we revert 2d78c6b ?" because answer is "No."

This reverts commit d27c4f9.

* more explicit skip

---------

Co-authored-by: Christophe REGOUBY <[email protected]>
  • Loading branch information
cregouby and Christophe-Regouby authored Nov 14, 2024
1 parent cf26609 commit 37084e4
Show file tree
Hide file tree
Showing 8 changed files with 1,505 additions and 12 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# torch (development version)
# torch (development version)

## Bug fixes

- Fix french translation (#1176 @cregouby)

## Bug fixes

Expand Down
14 changes: 7 additions & 7 deletions R/conditions.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
value_error <- function(..., env = rlang::caller_env()) {
rlang::abort(glue::glue(..., .envir = env), class = "value_error")
rlang::abort(glue::glue(gettext(...)[[1]], .envir = env), class = "value_error")
}

type_error <- function(..., env = rlang::caller_env()) {
rlang::abort(glue::glue(..., .envir = env), class = "type_error")
rlang::abort(glue::glue(gettext(..., domain = "R-torch")[[1]], .envir = env), class = "type_error")
}

runtime_error <- function(..., env = rlang::caller_env()) {
rlang::abort(glue::glue(..., .envir = env), class = "runtime_error")
rlang::abort(glue::glue(gettext(..., domain = "R-torch")[[1]], .envir = env), class = "runtime_error")
}

not_implemented_error <- function(..., env = rlang::caller_env()) {
rlang::abort(glue::glue(..., .envir = env), class = "not_implemented_error")
rlang::abort(glue::glue(gettext(..., domain = "R-torch")[[1]], .envir = env), class = "not_implemented_error")
}

warn <- function(..., env = rlang::caller_env()) {
rlang::warn(glue::glue(..., .envir = env), class = "warning")
rlang::warn(glue::glue(gettext(..., domain = "R-torch")[[1]], .envir = env), class = "warning")
}

stop_iteration_error <- function(..., env = rlang::caller_env()) {
rlang::abort(glue::glue(..., .envir = env), class = "stop_iteration_error")
rlang::abort(glue::glue(gettext(..., domain = "R-torch")[[1]], .envir = env), class = "stop_iteration_error")
}

inform <- rlang::inform

deprecated <- function(..., env = rlang::caller_env()) {
rlang::warn(..., class = "deprecated")
rlang::warn(gettext(..., domain = "R-torch")[[1]], class = "deprecated")
}
2 changes: 1 addition & 1 deletion R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ is_url <- function(x) {
#' @export
get_install_libs_url <- function(version = NA, type = NA) {
if (!is.na(type)) {
cli::cli_abort("Please use the env vars describe in {.fn install_torch} to configure the installation type.")
cli::cli_abort("Please use the env vars described in {.fn install_torch} to configure the installation type.")
}
if (!is.na(version)) {
cli::cli_abort("It's not possible to configure the libtorch version.")
Expand Down
2 changes: 1 addition & 1 deletion R/optim-lr_scheduler.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LRScheduler <- R6::R6Class(
optimizer$param_groups,
function(group) {
if (is.null(group[["initial_lr"]])) {
value_error("param 'inital_lr' not is not specified.")
value_error("param 'inital_lr' is not specified.")
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions R/save.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ legacy_save_nn_module <- function(obj, path, ..., compress = TRUE) {

#' @export
torch_save.name <- function(obj, path, ..., compress= TRUE) {
if (!is_exhausted(obj)) rlang::abort("Cannot save `name` objects.")
if (!is_exhausted(obj)) rlang::abort("Cannot save `name` object.")
saveRDS(list(type = "coro::exhausted", version = use_ser_version()), path,
compress = compress)
}
Expand Down Expand Up @@ -484,7 +484,7 @@ create_write_con <- function(path) {
con <- if (is.character(path)) {
file(path, open = "wb")
} else {
cli::cli_abort("{.arg path} must be a connection or a actual path, got {.cls {class(path)}}.")
cli::cli_abort("{.arg path} must be a connection or an actual path, got {.cls {class(path)}}.")
}

withr::defer_parent({close(con)})
Expand Down
Binary file added inst/po/fr/LC_MESSAGES/R-torch.mo
Binary file not shown.
Loading

0 comments on commit 37084e4

Please sign in to comment.