Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect DESCRIPTION language. #2808

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
if (!is.null(pkg$meta$url)) {
pkg$meta$url <- sub("/$", "", pkg$meta$url)
}

pkg$development <- meta_development(pkg)
pkg$prefix <- pkg$development$prefix

Expand All @@ -85,7 +85,7 @@
pkg$dst_path <- path(pkg$dst_path, pkg$development$destination)
}

pkg$lang <- pkg$meta$lang %||% "en"
pkg$lang <- get_pkg_lang(pkg)
pkg$install_metadata <- config_pluck_bool(pkg, "deploy.install_metadata", FALSE)
pkg$figures <- meta_figures(pkg)
pkg$repo <- package_repo(pkg)
Expand All @@ -106,6 +106,21 @@
desc::description$new(path)
}

get_pkg_lang <- function(pkg) {
if (!is.null(pkg$meta$lang)) {
return(pkg$meta$lang)

Check warning on line 111 in R/package.R

View check run for this annotation

Codecov / codecov/patch

R/package.R#L111

Added line #L111 was not covered by tests
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
}

if (pkg$desc$has_fields("Language")) {
field <- pkg$desc$get_field("Language")
if (length(field) && nchar(field) > 0) {
return(regmatches(field, regexpr("[^,]+", field)))

Check warning on line 117 in R/package.R

View check run for this annotation

Codecov / codecov/patch

R/package.R#L115-L117

Added lines #L115 - L117 were not covered by tests
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
}
}

return("en")
}

get_bootstrap_version <- function(pkg,
template,
template_package = NULL,
Expand Down Expand Up @@ -270,7 +285,7 @@
fig <- extract_figure(desc)

if (!is.null(fig) && length(fig) > 0 && length(fig[[1]]) > 0) {
path <- as.character(fig[[1]][[1]])
path <- as.character(fig[[1]][[1]])
if (grepl("lifecycle", path)) {
name <- gsub("lifecycle-", "", path)
name <- path_ext_remove(name)
Expand Down Expand Up @@ -351,12 +366,12 @@
if (path_ext(path) == "qmd") {
inspect <- quarto::quarto_inspect(path)
meta <- inspect$formats[[1]]$metadata

out <- list(
title = meta$title %||% "UNKNOWN TITLE",
desc = meta$description %||% NA_character_,
ext = path_ext(inspect$formats[[1]]$pandoc$`output-file`) %||% "html"
)
)
} else {
yaml <- rmarkdown::yaml_front_matter(path)
out <- list(
Expand Down
Loading