Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Translate into French
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Nov 12, 2024
1 parent 1f67b4b commit 9cdf61c
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 36 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# aion 1.1.0.9000
## Enhancements
* Translate into French.

# aion 1.1.0
## New classes and methods
Expand Down
5 changes: 5 additions & 0 deletions R/aion-internal.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# HELPERS

## https://michaelchirico.github.io/potools/articles/developers.html
tr_ <- function(...) {
enc2utf8(gettext(paste0(...), domain = "R-aion"))
}

make_par <- function(params, x, n = 1) {
p <- params[[x]] %||% graphics::par()[[x]]
if (length(p) == 1 && n > 1) p <- rep(p, length.out = n)
Expand Down
34 changes: 17 additions & 17 deletions R/calendar.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ setMethod(
#' @describeIn gregorian Gregorian BP era.
BP <- function(...) {
.GregorianCalendar(
label = "BP",
name = "Before Present",
label = tr_("BP"),
name = tr_("Before Present"),
epoch = 1950,
direction = -1L
)
Expand All @@ -38,8 +38,8 @@ BP <- function(...) {
#' @describeIn gregorian Gregorian b2k era.
b2k <- function(...) {
.GregorianCalendar(
label = "b2k",
name = "Before 2000",
label = tr_("b2k"),
name = tr_("Before 2000"),
epoch = 2000,
direction = -1L
)
Expand All @@ -49,8 +49,8 @@ b2k <- function(...) {
#' @describeIn gregorian Gregorian BC era.
BC <- function(...) {
.GregorianCalendar(
label = "BC",
name = "Before Christ",
label = tr_("BC"),
name = tr_("Before Christ"),
direction = -1L
)
}
Expand All @@ -59,8 +59,8 @@ BC <- function(...) {
#' @describeIn gregorian Gregorian BCE era.
BCE <- function(...) {
.GregorianCalendar(
label = "BCE",
name = "Before Common Era",
label = tr_("BCE"),
name = tr_("Before Common Era"),
direction = -1L
)
}
Expand All @@ -69,26 +69,26 @@ BCE <- function(...) {
#' @describeIn gregorian Gregorian AD era.
AD <- function(...) {
.GregorianCalendar(
label = "AD",
name = "Anno Domini"
label = tr_("AD"),
name = tr_("Anno Domini")
)
}

#' @export
#' @describeIn gregorian Gregorian CE era.
CE <- function(...) {
.GregorianCalendar(
label = "CE",
name = "Common Era"
label = tr_("CE"),
name = tr_("Common Era")
)
}

# @export
# @describeIn gregorian Gregorian AUC era.
# AUC <- function(...) {
# .GregorianCalendar(
# label = "AUC",
# name = "Ab urbe condita",
# label = tr_("AUC"),
# name = tr_("Ab urbe condita"),
# epoch = 753,
# direction = 1
# )
Expand Down Expand Up @@ -132,9 +132,9 @@ setMethod(
f = "calendar_unit",
signature = "TimeScale",
definition = function(object) {
if (is_gregorian(object)) return("Gregorian")
if (is_julian(object)) return("Julian")
return("Undefined")
if (is_gregorian(object)) return(tr_("Gregorian years"))
if (is_julian(object)) return(tr_("Julian years"))
return(tr_("Undefined"))
}
)

Expand Down
2 changes: 1 addition & 1 deletion R/intervals.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ setMethod(

## End
if (methods::is(end, "RataDie")) {
msg <- "%s is already expressed in rata die: %s is ignored."
msg <- tr_("%s is already expressed in rata die: %s is ignored.")
warning(sprintf(msg, sQuote("end"), sQuote("calendar")), call. = FALSE)
} else {
end <- fixed(end, calendar = calendar, scale = scale)
Expand Down
2 changes: 1 addition & 1 deletion R/series.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ setMethod(
signature = c(object = "array", time = "numeric", calendar = "TimeScale"),
definition = function(object, time, calendar, scale = 1, names = NULL) {
if (methods::is(time, "RataDie")) {
msg <- "%s is already expressed in rata die: %s is ignored."
msg <- tr_("%s is already expressed in rata die: %s is ignored.")
warning(sprintf(msg, sQuote("time"), sQuote("calendar")), call. = FALSE)
} else {
time <- fixed(time, calendar = calendar, scale = scale)
Expand Down
32 changes: 17 additions & 15 deletions R/show.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ setMethod(
f = "format",
signature = "TimeScale",
definition = function(x) {
label <- calendar_label(x)
label <- if (length(label) > 0) sprintf(" %s", label) else ""

sprintf("%s years%s", calendar_unit(x), label)
msg <- sprintf("%s %s", calendar_unit(x), calendar_label(x))
trimws(msg)
}
)

Expand All @@ -36,7 +34,6 @@ setMethod(
definition = function(x, prefix = c("a", "ka", "Ma", "Ga"), label = TRUE,
calendar = getOption("aion.calendar")) {
if (is.null(calendar)) return(format(as.numeric(x)))

y <- as_year(x, calendar = calendar)

## Scale
Expand All @@ -52,7 +49,7 @@ setMethod(

prefix <- if (power > 1) sprintf(" %s", prefix) else ""
label <- if (isTRUE(label)) sprintf(" %s", calendar_label(calendar)) else ""
sprintf("%g%s%s", y / power, prefix, label)
trimws(sprintf("%g%s%s", y / power, prefix, label))
}
)

Expand All @@ -61,21 +58,26 @@ setMethod(
f = "show",
signature = "TimeScale",
definition = function(object) {
dirout <- if (calendar_direction(object) > 0) "forwards" else "backwards"
era <- sprintf("%s (%s): ", calendar_name(object), calendar_label(object))
if (length(era) == 0) era <- ""
era <- ""
if (calendar_name(object) != "" && calendar_label(object) != "") {
era <- sprintf("%s (%s): ", calendar_name(object), calendar_label(object))
}

msg <- "%s%s years counted %s from %g."
msg <- sprintf(msg, era, calendar_unit(object), dirout, calendar_epoch(object))
cat(msg, sep = "\n")
if (calendar_direction(object) > 0) {
msg <- tr_("%s%s counted forwards from %g.")
} else {
msg <- tr_("%s%s counted backwards from %g.")
}
msg <- sprintf(msg, era, calendar_unit(object), calendar_epoch(object))
cat(trimws(msg), sep = "\n")
}
)

setMethod(
f = "show",
signature = "RataDie",
definition = function(object) {
msg <- "Rata die: number of days since 01-01-01 (Gregorian)."
msg <- tr_("Rata die: number of days since 01-01-01 (Gregorian).")
cat(msg, sep = "\n")
methods::callGeneric(object@.Data)
}
Expand All @@ -88,7 +90,7 @@ setMethod(
n <- dim(object)
start <- format(start(object))
end <- format(end(object))
msg <- "%d x %d x %d time series observed between %s and %s r.d."
msg <- tr_("%d x %d x %d time series observed between %s and %s r.d.")
msg <- sprintf(msg, n[1L], n[2L], n[3L], start, end)
cat(msg, sep = "\n")
}
Expand All @@ -101,7 +103,7 @@ setMethod(
n <- length(object)
start <- format(min(start(object)))
end <- format(max(end(object)))
msg <- "%d time intervals observed between %s and %s r.d."
msg <- tr_("%d time intervals observed between %s and %s r.d.")
msg <- sprintf(msg, n, start, end)
cat(msg, sep = "\n")
}
Expand Down
2 changes: 1 addition & 1 deletion R/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ assert_ordered <- function(start, end) {
arg_start <- deparse(substitute(start))
arg_end <- deparse(substitute(end))
if (any(start > end)) {
msg <- sprintf("%s is younger than %s.", sQuote(arg_start), sQuote(arg_end))
msg <- sprintf(tr_("%s is later than %s."), sQuote(arg_start), sQuote(arg_end))
stop(msg)
}
invisible(NULL)
Expand Down
Binary file added inst/po/fr/LC_MESSAGES/R-aion.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions inst/tinytest/test_calendar.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Sys.setenv(LANGUAGE = "en") # Force locale
options(aion.calendar = calendar("CE"))

# Unknown calendar =============================================================
expect_error(calendar("XXX"), "Unknown calendar")

Expand Down
5 changes: 4 additions & 1 deletion inst/tinytest/test_intervals.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Sys.setenv(LANGUAGE = "en") # Force locale
options(aion.calendar = calendar("CE"))

# Create =======================================================================
lower <- c(625, 700, 1200, 1225, 1250, 500, 1000, 1200,
1325, 1375, 1200, 1300, 1375, 1275, 1325)
Expand All @@ -7,7 +10,7 @@ upper <- c(750, 825, 1250, 1275, 1325, 700, 1300, 1325,
x <- intervals(start = lower, end = upper, calendar = CE())
expect_identical(length(x), 15L)

expect_error(intervals(start = upper, end = lower, calendar = CE()), "is younger than")
expect_error(intervals(start = upper, end = lower, calendar = CE()), "is later than")

lower_rd <- fixed(lower, calendar = CE())
upper_rd <- fixed(upper, calendar = CE())
Expand Down
3 changes: 3 additions & 0 deletions inst/tinytest/test_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ if (at_home()) {
options(tinysnapshot_tol = 200) # pixels
options(tinysnapshot_os = "Linux")

Sys.setenv(LANGUAGE = "en") # Force locale
options(aion.calendar = calendar("CE"))

# Plot multiple ==============================================================
X <- series(
object = matrix(sin(1:300), nrow = 50, ncol = 6),
Expand Down
3 changes: 3 additions & 0 deletions inst/tinytest/test_series.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Sys.setenv(LANGUAGE = "en") # Force locale
options(aion.calendar = calendar("CE"))

# Create from vector ===========================================================
x <- rnorm(91)

Expand Down
3 changes: 3 additions & 0 deletions inst/tinytest/test_show.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Sys.setenv(LANGUAGE = "en") # Force locale
options(aion.calendar = calendar("CE"))

# Format =======================================================================
expect_identical(format(CE()), "Gregorian years CE")
expect_identical(format(J()), "Julian years")
Expand Down
103 changes: 103 additions & 0 deletions po/R-aion.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
msgid ""
msgstr ""
"Project-Id-Version: aion 1.1.0.9000\n"
"POT-Creation-Date: 2024-11-12 14:09+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: calendar.R:21
msgid "Unknown calendar: %s"
msgstr ""

#: calendar.R:30
msgid "BP"
msgstr ""

#: calendar.R:31
msgid "Before Present"
msgstr ""

#: calendar.R:41
msgid "b2k"
msgstr ""

#: calendar.R:42
msgid "Before 2000"
msgstr ""

#: calendar.R:52
msgid "BC"
msgstr ""

#: calendar.R:53
msgid "Before Christ"
msgstr ""

#: calendar.R:62
msgid "BCE"
msgstr ""

#: calendar.R:63
msgid "Before Common Era"
msgstr ""

#: calendar.R:72
msgid "AD"
msgstr ""

#: calendar.R:73
msgid "Anno Domini"
msgstr ""

#: calendar.R:81
msgid "CE"
msgstr ""

#: calendar.R:82
msgid "Common Era"
msgstr ""

#: calendar.R:135
msgid "Gregorian years"
msgstr ""

#: calendar.R:136
msgid "Julian years"
msgstr ""

#: calendar.R:137
msgid "Undefined"
msgstr ""

#: intervals.R:44 series.R:43
msgid "%s is already expressed in rata die: %s is ignored."
msgstr ""

#: show.R:67
msgid "%s%s counted forwards from %g."
msgstr ""

#: show.R:69
msgid "%s%s counted backwards from %g."
msgstr ""

#: show.R:80
msgid "Rata die: number of days since 01-01-01 (Gregorian)."
msgstr ""

#: show.R:93
msgid "%d x %d x %d time series observed between %s and %s r.d."
msgstr ""

#: show.R:106
msgid "%d time intervals observed between %s and %s r.d."
msgstr ""

#: validate.R:87
msgid "%s is later than %s."
msgstr ""
Loading

0 comments on commit 9cdf61c

Please sign in to comment.