pbs-assess / rosettafish

:fishing_pole_and_fish: An R package for translating fish- and fisheries-related terms
2 stars 14 forks source link

Consider adding a units argument #6

Closed seananderson closed 4 years ago

seananderson commented 5 years ago

Would be pasted after the main label and surrounded by parentheses if the argument was present. Could be taken from a separate dictionary file to keep things organized and the lookup tables smaller. Or could be part of the same lookup.

andrew-edwards commented 5 years ago

So to avoid having Biomass (kg) Biomass (t) etc. in the dictionary file, yes?

Maybe it could separately translate the main term and the units, where the units are in parentheses?

grinnellm commented 5 years ago

Some of the herring (and probably others) axes have complex units with math. It would be nice to accommodate these too: y=expression(paste("Spawn index (t"%*%10^3, ")", sep="")) for "Spawn index (t x 10^3)".

seananderson commented 5 years ago

The simplest way would be to just use:

paste(en2fr("Spawn index") (t"%*%10^3, ")", sep="")

or something along those lines (that might need to be tweaked to work with expression) rather than complicating things on the backend. I.e., more generally, paste(en2fr("Label to translate"), "(my units)")

Also, in the original example, paste0() would be a bit shorter.