Add new template functions for internal error/warning/message to ease translation#5056
Add new template functions for internal error/warning/message to ease translation#5056
Conversation
| bad.counts = name.tab[1 < name.tab] | ||
| if (length(bad.counts)) { | ||
| stop(err.what, " should be uniquely named, problems: ", paste(names(bad.counts), collapse=",")) | ||
| stopf("%s should be uniquely named, problems: %s", err.what, brackify(names(bad.counts))) |
There was a problem hiding this comment.
@tdhock FYI I think in a follow-up to this PR we'll want to revisit error messages here, it's not very translation-friendly at the moment (not a high priority)
There was a problem hiding this comment.
sure that is fine with me. what exactly does it mean to be translation-friendly?
There was a problem hiding this comment.
in this case, we would have to have translators translate sentence fragments in isolation. the way to combine those fragments as we do here in English is likely to be different in other languages.
There was a problem hiding this comment.
ok that makes sense, so in this case err.what has three possible values, "measured columns", "elements of fun.list", "... arguments to measure" which we should convert to three separate calls to stop, for example the first one becomes "measured columns should be uniquely named, problems: "
There was a problem hiding this comment.
that sounds good... full sentences are usually good
R/fread.R
Outdated
| ngettext( | ||
| sum(idx_type), | ||
| 'colClasses dictated by user input and those read from YAML header are in conflict (specifically, for column [%s]); the proceeding assumes the user input was an intentional override and will ignore the types implied by the YAML header; please exclude this column from colClasses if this was unintentional.', | ||
| 'colClasses dictated by user input and those read from YAML header are in conflict (specifically, for columns [%s]); the proceeding assumes the user input was an intentional override and will ignore the types implied by the YAML header; please exclude these columns from colClasses if this was unintentional.' |
There was a problem hiding this comment.
Can this be reduced to one string using "column(s)" and "these columns" always? I'm thinking "these columns" still reads ok when there's just one, because "column(s)" occurs earlier in the message. Then this could be one call to messagef(), simpler and without repeating the long message string.
Or perhaps "column(s)" is hard to translate?
There was a problem hiding this comment.
I think we're safe for now because Chinese doesn't really have pluralization, and I only see maybe extending to a few romance languages (which will have similar pluralization to English), so I agree it's nice to reduce the overhead here given how clunky ngettext() is. we can revisit in the future on request.
i also just wrote a message elsewhere that is like start(s): %d; end(s); %d, which, IINM, would require nested ngettext()` calls to "properly" pluralize. yuck.
|
Awesome PR. This solves this area very nicely. Re 1-3 thoughts in top comment :
|
|
I realized what I was suggesting was a bit tricky so I had a go in 0e45b19. |
|
Since pluralization will need a future PR anyway either for this one or the other similar ones, merging now to make progress, so we can start using |
|
Sounds good, working on a follow-up now. |
potoolsinvocation helping us out here (I'll write this in CRAN_release oncepotoolsitself lands on CRAN):A few thoughts
nstopf()?) to wrap the somewhat uglystop(domain=NA, sprintf(ngettext(n, msg1, msg2), ...))case (and of course nwarningf/nmessagef)potools::get_message_data()will facilitate this by getting a data set of messages.