Bug 14605

Summary: Domain search in ngettext() is broken
Product: R Reporter: Mikko Korpela <mvkorpel>
Component: MiscAssignee: R-core <R-core>
Status: CLOSED FIXED    
Severity: minor CC: murdoch
Priority: P5    
Version: R 2.13.1   
Hardware: x86_64/x64/amd64 (64-bit)   
OS: Linux   
Bug Depends on:    
Bug Blocks: 14656    
Attachments: Minimal package that reproduces the bug
Example output when translation is not available
Example output when translation is available

Description Mikko Korpela 2011-06-14 20:26:40 UTC
The reporter of the CLOSED bug 14367 notes that there is a difference between do_gettext() and do_ngettext() where a break statement exists in the latter function but not in the former one.

I suspect that do_ngettext() is broken. In my experiments (sorry, no easy test case available here), ngettext() cannot detect the correct domain and does not produce a translation unless the domain is given as a parameter.

I find that removing the break on line 952 of errors.c (R 2.13.0) fixes the domain detection in ngettext(). Again, I'm sorry for the lack of an example. If the problem cannot be easily reproduced, I will take the time to prepare some kind of an example. The problem was discovered with a development version of the package dplR which I'm also working on. The current version in R-Forge (SVN revision 173) works around the problem by specifying the domain in all calls to ngettext().

I don't claim intimate knowledge of the code, but I don't see a reason why one of the similar functions do_gettext() and do_ngettext() should have the break and the other one not. To me it seems that the special treatment of "stop", "warning" and "message" in do_gettext() doesn't explain the absence or presence of break. If gettext() or ngettext() is called by the user (not by "stop", "warning" or "message"), the only remaining difference (the continue branch is not taken) in the domain detection codes of the functions is the break sentence, and I think there should be no difference.

The following session info refers to an unreleased version of dplR.

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplR_1.4.3

loaded via a namespace (and not attached):
[1] digest_0.5.0    grid_2.13.0     lattice_0.19-26 XML_3.4-0      

> Sys.getenv("LANGUAGE")
[1] "fi"
Comment 1 Brian Ripley 2011-08-08 17:42:54 UTC
Still nothing to reproduce.
Comment 2 Mikko Korpela 2011-08-08 19:55:01 UTC
Created attachment 1215 [details]
Minimal package that reproduces the bug
Comment 3 Mikko Korpela 2011-08-08 19:57:16 UTC
Created attachment 1216 [details]
Example output when translation is not available

R version 2.13.1 was used
Comment 4 Mikko Korpela 2011-08-08 19:58:05 UTC
Created attachment 1217 [details]
Example output when translation is available

R version 2.13.1 was used
Comment 5 Brian Ripley 2011-08-12 07:30:31 UTC
*** Bug 14656 has been marked as a duplicate of this bug. ***
Comment 6 Duncan Murdoch 2015-12-14 17:58:24 UTC
I see the bug, and will look at the patch.
Comment 7 Duncan Murdoch 2015-12-14 19:20:15 UTC
I've now fixed this, and will soon commit to R-devel and R-patched.  I didn't use your patch, rather a more elaborate version to make gettext() and ngettext() more similar.