A short overview of the problem: Automatic domain in ngettext() does not
work when used inside a package.

How to test:
1. Download the small test package "minimal_1.0-0.tar.gz" attached to
the bug report.
2. As the package contains Finnish translations, start R with Finnish
language settings. Prepending "LANGUAGE=fi " to the command line that
starts R works for me on Linux, if there are no conflicting settings in
the R startup files.
3. Run the following commands:
   library(minimal)
   test.with.domain()
   test.without.domain()
4. If all the text you see is in English, the language setting was not
applied correctly. Otherwise, if the test functions produced different
output, the problem has been demonstrated.

After applying the change in the attached file, the test functions
produce identical output, which means that ngettext() uses the package
translation domain if no other domain is specified.

I also think that ‘ngettext’ should probably be mentioned in this
paragraph of the ?gettext manual:

>     If ‘domain’ is ‘NULL’ or ‘""’, and ‘gettext’ is called from a
>     function in the namespace of package ‘pkg’ the domain is set to
>     ‘"R-pkg"’.  Otherwise there is no default domain.

At least "1.8.2 R messages" in R-exts implies that automatic domain
applies to ngettext(), too.

Tested on "R Under development (unstable) (2015-12-14 r69773)",
Platform: x86_64-pc-linux-gnu (64-bit).

-- 
Mikko Korpela
Aalto University School of Science
Department of Computer Science
Index: src/main/errors.c
===================================================================
--- src/main/errors.c	(revision 69773)
+++ src/main/errors.c	(working copy)
@@ -1057,7 +1057,6 @@
 	     cptr = cptr->nextcontext)
 	    if (cptr->callflag & CTXT_FUNCTION) {
 		rho = cptr->cloenv;
-		break;
 	    }
 	while(rho != R_EmptyEnv) {
 	    if (rho == R_GlobalEnv) break;
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to