Closed hadley closed 2 years ago
I think gettextf("Source: %s", toString(links))
would lead to the most translate-able template.
glue_collapse()
is a bit tougher... maybe glue_collapse()
itself should get a domain
argument?
Tangentially related: Gergey Daróczi also raised the interesting idea of using glue templates and gettext()
instead of gettextf()
:
gettext(glue::glue("Source: {link_list}"))
# or
gettext(glue::glue("Source: {toString(link_list)}")
Advantages:
%1$s
redirection templates which are pretty clunkyDisadvantage:
I think you mean glue::glue(gettext("Source: {link_list}"))
, but yeah totally agreed. It's seems much easier to understand multi-component messages when the components are given named instead of numbers. I think that the downsides are small in practice.
toString()
isn't localised either, but presumably punctuation is more consistent across (most modern) languages.
I asked on twitter to get a sense for how this differs. Here's a summary:
(aやb、c)
= a {or} b, c
Comprehensive solution at https://github.com/rossellhayes/and
Looks great to be able to offload this to and
. Should that be functionality in glue
, though?
Yeah, I think it would make sense to either bundle the functionality with glue or with potools. It would be useful to have all translation related stuff in one place, but bundling it with potools would imply some packages would need to take a run-time dependency on potools and I don't know how you feel about that.
Right... it looks like and
is more of a "recommended package" from potools perspective. With gettextf()
potools would be basically agnostic to it:
gettextf("Valid arguments are: %s", toString(valid_args))
# vs
gettext(glue("Valid arguments are: {glue_collapse(valid_args)}"))
# vs
gettext(glue("Valid arguments are: {and(valid_args)}"))
So as I'm seeing it now, this could be Suggested & included in vignettes
Yeah good point. I'll leave this open to include in my vignette, but otherwise seems like there's nothing for potools to do.
Would have to think through the consequences of routinely using and()
in glue strings; it would be weird to see Valid arguments are aやb、c
if the rest of the string hasn't been translated.
Agreed... looks like, even for glue
, the best approach is to recommend it (maybe in the glue_collapse()
docs)
How should I translate code like this?
I can translate just the
Source
, but presumably languages have different conventions for this.Also worth considering
glue::glue_collapse()
or similar, which can generate phrases like"a, b, c, and d"