-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default to UTF-8 when writing .pot files (#300)
* default to UTF-8 when writing .pot files * add back line break Co-authored-by: Hadley Wickham <[email protected]> * update test of format(template=TRUE) output * NEWS --------- Co-authored-by: Hadley Wickham <[email protected]>
- Loading branch information
1 parent
a0eb5ec
commit 1904ee5
Showing
5 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ write_po_files <- function(message_data, po_dir, params, template = FALSE, use_b | |
if (is_base_package) { | ||
params$package <- "R" | ||
params$bugs <- "bugs.r-project.org" | ||
# #299: msg* commands work best with charset=UTF-8, | ||
# but the 'base' .pot files leave it unsepecified (CHARSET). | ||
if (template) params$charset <- "CHARSET" | ||
} | ||
|
||
if (template) { | ||
|
@@ -248,7 +251,7 @@ write_po_file <- function( | |
po_data[ , 'msgid_plural' := strsplit(msgid_plural, "|||", fixed = TRUE)] | ||
|
||
# tools::xgettext2pot() tries to make the entries' whitespace align, which xgettext doesn't do | ||
if (use_base_rules & po_data$message_source[1L] == "R") { | ||
if (use_base_rules && po_data$message_source[1L] == "R") { | ||
plural_fmt <- '\n%s%smsgid "%s"\nmsgid_plural "%s"\n%s' | ||
msgstr_fmt <- 'msgstr[%d] "%s"' | ||
} else { | ||
|
@@ -403,7 +406,7 @@ po_metadata = function(package='', version='', language='', author='', email='', | |
is.null(copyright) || is.character(copyright) || is.list(copyright) | ||
) | ||
pm = c(as.list(environment()), list(...)) | ||
pm$charset <- "UTF-8" | ||
if (is.null(pm$charset)) pm$charset <- "UTF-8" | ||
if (is.null(pm$pot_timestamp)) pm$pot_timestamp <- Sys.time() | ||
if (is.null(pm$po_timestamp)) pm$po_timestamp <- pm$pot_timestamp | ||
if (is.null(pm$language_team)) pm$language_team <- pm$language | ||
|
@@ -420,7 +423,6 @@ format.po_metadata = function(x, template = FALSE, use_plurals = FALSE, ...) { | |
x$email = "EMAIL@ADDRESS" | ||
x$language = '' | ||
x$language_team = "LANGUAGE <[email protected]>" | ||
x$charset = 'CHARSET' | ||
} | ||
if (is.character(x$copyright)) { | ||
x$copyright = list(years = format(x$pot_timestamp, "%Y"), holder = x$copyright) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ test_that("po_metadata constructor & methods work", { | |
format(metadata, template = TRUE), | ||
c( | ||
'"Language-Team: LANGUAGE <[email protected]>\\n"', | ||
'"Content-Type: text/plain; charset=CHARSET\\n"', | ||
'"Content-Type: text/plain; charset=UTF-8\\n"', | ||
'# SOME DESCRIPTIVE TITLE.', | ||
'# This file is distributed under the same license as the R package.', | ||
'# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.' | ||
|