Skip to content

Commit

Permalink
Missed/partial translations in setops/fread (#6536)
Browse files Browse the repository at this point in the history
* Missed/partial translations in setops/fread

* fully different message for warning vs. error

* unfragment devel message
  • Loading branch information
MichaelChirico authored Sep 27, 2024
1 parent 0c957c7 commit 3734726
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
10 changes: 5 additions & 5 deletions R/devel.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ update_dev_pkg = function(pkg="data.table", repo="https://Rdatatable.gitlab.io/d
if (upg) {
unloadNamespace(pkg) ## hopefully will release dll lock on Windows
utils::install.packages(pkg, repos=repo, type=type, lib=lib, ...)
msg_fmt = gettext("R %s package has been updated to %s (%s)\n")
} else {
msg_fmt = gettext("R %s package is up-to-date at %s (%s)\n")
}
cat(sprintf("R %s package %s %s (%s)\n",
pkg,
c("is up-to-date at","has been updated to")[upg+1L],
unname(read.dcf(system.file("DESCRIPTION", package=pkg, lib.loc=lib, mustWork=TRUE), fields=field)[, field]),
utils::packageVersion(pkg, lib.loc=lib)))
field_val = unname(read.dcf(system.file("DESCRIPTION", package=pkg, lib.loc=lib, mustWork=TRUE), fields=field)[, field])
cat(sprintf(msg_fmt, pkg, field_val, utils::packageVersion(pkg, lib.loc=lib)))
})
invisible(upg)
}
Expand Down
10 changes: 8 additions & 2 deletions R/fread.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,14 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC")
# finally:
methods::as(v, new_class))
},
warning = fun <- function(e) {
warningf("Column '%s' was requested to be '%s' but fread encountered the following %s:\n\t%s\nso the column has been left as type '%s'", names(ans)[j], new_class, if (inherits(e, "error")) "error" else "warning", e$message, typeof(v))
warning = fun <- function(c) {
# NB: branch here for translation purposes (e.g. if error/warning have different grammatical gender)
if (inherits(c, "warning")) {
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following warning:\n\t%s\nso the column has been left as type '%s'")
} else {
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following error:\n\t%s\nso the column has been left as type '%s'")
}
warningf(msg_fmt, names(ans)[j], new_class, conditionMessage(c), typeof(v), domain=NA)
v
},
error = fun)
Expand Down
12 changes: 6 additions & 6 deletions R/setops.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ all.equal.data.table = function(target, current, trim.levels=TRUE, check.attribu
k1 = key(target)
k2 = key(current)
if (!identical(k1, k2)) {
return(gettextf(
"Datasets have different %s. 'target': %s. 'current': %s.",
"keys",
return(sprintf(
"%s. 'target': %s. 'current': %s.",
gettext("Datasets have different keys"),
if(length(k1)) brackify(k1) else gettextf("has no key"),
if(length(k2)) brackify(k2) else gettextf("has no key")
))
Expand All @@ -168,9 +168,9 @@ all.equal.data.table = function(target, current, trim.levels=TRUE, check.attribu
i1 = indices(target)
i2 = indices(current)
if (!identical(i1, i2)) {
return(gettextf(
"Datasets have different %s. 'target': %s. 'current': %s.",
"indices",
return(sprintf(
"%s. 'target': %s. 'current': %s.",
gettext("Datasets have different indices"),
if(length(i1)) brackify(i1) else gettextf("has no index"),
if(length(i2)) brackify(i2) else gettextf("has no index")
))
Expand Down

0 comments on commit 3734726

Please sign in to comment.