Skip to content

Commit d9b0e64

Browse files
Merge branch 'master' into get-msg-deprecated
2 parents c093943 + 5e0557f commit d9b0e64

10 files changed

+47
-47
lines changed

R/check_cracked_messages.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ check_cracked_messages = function(message_data) {
6565
set(dup_messages, ii, "replacement", build_gettextf_call(dup_messages$call_expr[[ii]]))
6666
}
6767

68-
return(dup_messages[ , .(call, file, line_number, replacement)])
68+
dup_messages[ , .(call, file, line_number, replacement)]
6969
}
7070
attr(check_cracked_messages, "diagnostic_tag") =
7171
"R messaging calls that might be better suited for gettextf for ease of translation"
@@ -105,8 +105,8 @@ count_dots = function(call) {
105105
call,
106106
function(x) {
107107
e = match.call(definition, x)
108-
if (is.null(names(e))) return(length(e) - 1L)
109-
return(length(e) - sum(names(e) %chin% c("call.", "immediate.", "noBreaks.", "domain", "appendLF")) - 1L)
108+
n_excluded = sum(names(e) %chin% c("call.", "immediate.", "noBreaks.", "domain", "appendLF"))
109+
length(e) - n_excluded - 1L
110110
},
111111
integer(1L)
112112
)

R/check_untranslated_cat.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ check_untranslated_cat <- function(message_data) {
7575
set(cat_calls, ii, "replacement", build_suggested_cat_call(cat_calls$call_expr[[ii]]))
7676
}
7777

78-
return(cat_calls[
78+
cat_calls[
7979
nzchar(replacement),
8080
.(call, file, line_number, replacement)
81-
])
81+
]
8282
}
8383
attr(check_untranslated_cat, "diagnostic_tag") = "untranslated messaging calls passed through cat()"
8484

@@ -124,5 +124,5 @@ build_suggested_cat_call = function(e) {
124124
no_translated_subcall <- function(e) {
125125
if (!is.call(e)) return(TRUE)
126126
if (is.name(e[[1L]]) && e[[1L]] %chin% c("gettext", "gettextf", "ngettext")) return(FALSE)
127-
return(all(vapply(e[-1L], no_translated_subcall, logical(1L))))
127+
all(vapply(e[-1L], no_translated_subcall, logical(1L)))
128128
}

R/check_untranslated_src.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
check_untranslated_src <- function(message_data) {
4545
if (!is.data.table(message_data)) message_data = as.data.table(message_data)
4646

47-
return(message_data[
47+
message_data[
4848
message_source == "src" & !is_marked_for_translation,
4949
.(call, file, line_number, replacement = NA_character_)
50-
])
50+
]
5151
}
5252
attr(check_untranslated_src, "diagnostic_tag") <- "src messaging calls that were not properly marked for translation"

R/explain_plurals.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ po_explain_plurals <- function(language, index) {
4747
)
4848
]
4949
}
50-
return(invisible())
50+
invisible()
5151
}
5252

5353
# just here to generate translations. comes from the PLURAL_RANGE_STRINGS csv

R/get_r_messages.R

+26-26
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ parse_r_files = function(dir, is_base) {
197197
return(out)
198198
}
199199
names(out) = r_files
200-
return(out)
200+
out
201201
}
202202

203203
# inspired by the --keyword argument in gettext, but customized to make sense for R.
@@ -463,32 +463,32 @@ drop_suppressed_and_named = function(calls_data, expr_data, target_args) {
463463
build_call = function(lines, comments, params) {
464464
if (params$line1 == params$line2) {
465465
return(substr(adjust_tabs(lines[params$line1]), params$col1, params$col2))
466-
} else {
467-
lines = lines[params$line1:params$line2]
468-
469-
# substring not substr here so we can eschew providing
470-
# last=nchar(lines[1L]) because we'd need to recalculate it after adjust_tabs()
471-
lines[1L] = substring(adjust_tabs(lines[1L]), params$col1)
472-
lines[length(lines)] = substring(adjust_tabs(lines[length(lines)]), 1L, params$col2)
473-
474-
# strip comments, _after_ getting the tab-adjusted column #s
475-
for (ii in seq_len(nrow(comments))) {
476-
# we've already subset lines, so line numbers have to be re-mapped
477-
adj_line_idx = comments$line1[ii] - params$line1 + 1L
478-
# column number has to be re-mapped relative to col1 as well, but only on line1 itself
479-
col_adj = if (adj_line_idx == 1L) params$col1 else 1L
480-
lines[adj_line_idx] = substr(
481-
lines[adj_line_idx],
482-
1L,
483-
comments$col1[ii] - col_adj
484-
)
485-
}
466+
}
486467

487-
# strip internal whitespace across lines in the call
488-
# NB: eventually, this will need to be smarter about multi-line STR_CONST...
489-
# for now, just wave hands around those....
490-
return(paste(trimws(lines), collapse = " "))
468+
lines = lines[params$line1:params$line2]
469+
470+
# substring not substr here so we can eschew providing
471+
# last=nchar(lines[1L]) because we'd need to recalculate it after adjust_tabs()
472+
lines[1L] = substring(adjust_tabs(lines[1L]), params$col1)
473+
lines[length(lines)] = substring(adjust_tabs(lines[length(lines)]), 1L, params$col2)
474+
475+
# strip comments, _after_ getting the tab-adjusted column #s
476+
for (ii in seq_len(nrow(comments))) {
477+
# we've already subset lines, so line numbers have to be re-mapped
478+
adj_line_idx = comments$line1[ii] - params$line1 + 1L
479+
# column number has to be re-mapped relative to col1 as well, but only on line1 itself
480+
col_adj = if (adj_line_idx == 1L) params$col1 else 1L
481+
lines[adj_line_idx] = substr(
482+
lines[adj_line_idx],
483+
1L,
484+
comments$col1[ii] - col_adj
485+
)
491486
}
487+
488+
# strip internal whitespace across lines in the call
489+
# NB: eventually, this will need to be smarter about multi-line STR_CONST...
490+
# for now, just wave hands around those....
491+
paste(trimws(lines), collapse = " ")
492492
}
493493

494494
adjust_tabs = function(l) {
@@ -526,7 +526,7 @@ clean_text = function(x) {
526526
# e.g. in 'a string with an \"escaped\" quote', the escapes for " disappear after parsing. See #128
527527
x = gsub("(?:^|(?<![\\\\]))[\\\\](['\"])", "\\1", x, perl = TRUE)
528528
x = gsub('\\\\', '\\', x, fixed = TRUE)
529-
return(x)
529+
x
530530
}
531531

532532
string_schema = function() {

R/get_src_messages.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ preprocess = function(contents) {
345345
)
346346
ii = ii + 1L
347347
}
348-
return(contents)
348+
contents
349349
}
350350

351351
is_outside_char_array = function(char_pos, arrays) {
@@ -410,7 +410,7 @@ match_parens = function(file, contents, arrays) {
410410
all_parens[idx & lparen, "paren_end" := fcase(!next_paren, next_start)]
411411
all_parens[ , c("next_paren", "next_start") := NULL]
412412
}
413-
return(all_parens[(lparen)])
413+
all_parens[(lparen)]
414414
}
415415

416416
build_msgid = function(left, right, starts, ends, contents) {
@@ -474,7 +474,7 @@ build_msgid_plural = function(fun, left, right, starts, ends, contents, message_
474474
msgid = paste(safe_substring(contents, starts[ii:jj - 1L] + 1L, ends[ii:jj - 1L] - 1L), collapse = '')
475475
msgid_plural = msgid
476476
}
477-
return(list(msgid_plural))
477+
list(msgid_plural)
478478
}
479479

480480
get_grout = function(left, right, starts, ends, contents) {

R/msgmerge.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ run_msgfmt = function(po_file, mo_file, verbose) {
5454
immediate. = TRUE
5555
)
5656
}
57-
return(invisible())
57+
invisible()
5858
}
5959

6060
update_en_quot_mo_files <- function(dir, verbose) {
@@ -73,7 +73,7 @@ update_en_quot_mo_files <- function(dir, verbose) {
7373
)
7474
unlink(po_file)
7575
}
76-
return(invisible())
76+
invisible()
7777
}
7878

7979
# https://www.gnu.org/software/gettext/manual/html_node/msginit-Invocation.html

R/read_translation.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ set_prompt_conn <- function() {
7979
conn <- file(conn, "r")
8080
}
8181
assign("prompt_conn", conn, envir=.potools)
82-
return(invisible())
82+
invisible()
8383
}
8484

8585
unset_prompt_conn <- function() {
86-
if (!exists("prompt_conn", envir=.potools) || inherits(.potools$prompt_conn, "terminal")) return(invisible())
87-
close(.potools$prompt_conn)
88-
return(invisible())
86+
if (exists("prompt_conn", envir=.potools) && !inherits(.potools$prompt_conn, "terminal"))
87+
close(.potools$prompt_conn)
88+
invisible()
8989
}
9090

9191
# would be great to use readline() but it has several fatal flaws:

R/specials_metadata.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,5 @@ all.equal.specials_metadata = function(target, current, ...) {
127127
# found in x, not y (i.e., in msgid, not msgstr)
128128

129129
# else target/current have the same number of rows
130-
return(TRUE)
130+
TRUE
131131
}

R/utils.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ get_directory = function(dir) {
88
if (!file.info(dir)$isdir) {
99
stopf('%s is not a directory', dir)
1010
}
11-
return(normalizePath(dir))
11+
normalizePath(dir)
1212
}
1313

1414
# check dir is a package & return its name & version
@@ -95,7 +95,7 @@ list_package_files = function(dir, subdir, subsubdirs = character(), pattern = N
9595
`%is_base_call%` = function(e, f) {
9696
if (e %is_name% f) return(TRUE)
9797
if (!is.call(e) || length(e) != 3L) return(FALSE)
98-
return(e[[1L]] %is_name% "::" && e[[2L]] %is_name% "base" && e[[3L]] %is_name% f)
98+
e[[1L]] %is_name% "::" && e[[2L]] %is_name% "base" && e[[3L]] %is_name% f
9999
}
100100

101101
gettextify = function(e, sep = '') {

0 commit comments

Comments
 (0)