[Pharo-users] Pluralising messages or choosing word alternatives

Esteban Maringolo emaringolo at gmail.com
Wed Feb 20 16:21:20 EST 2019

Why not use the condition macro so you have a single string literal, that
in the future could be used for translation?

| occurences |
occurences := 3.
'There <1?is:are> <2p> <1?occurrence:ocurrences> of <3p>' expandMacrosWith:
occurences = 1 with: 3 with: 'Foo'

Esteban A. Maringolo

El mié., 20 feb. 2019 a las 18:08, Tim Mackinnon (<tim at testit.works>)

> I was browsing some of the Pharo issues (always worth doing) - and noticed
> an interesting one about Test results reporting and pluralisation
> (https://github.com/pharo-project/pharo/issues/2578)
> In it, I hadn't noticed String>>asPluralBasedOn: before (and judging from
> many messages in the image, many others hadn't either).
> I'm fixing something similar for a refactoring bug and can use this
> technique there (although from memory, it comes with a health warning as if
> ever we want to internalise the messages in Pharo, this will need a
> different approach). However we are probably a distance from doing that -
> so cleaning up what we have is a good start.
> Anyway I was curious if there is something to help with messages like:
> ‘There is 1 occurrence of {1}’  vs ‘There are many occurrences of {1}’,
> which I’d like to write something like:
> ‘There ‘,  (‘is 1 ’, ‘are many ’) pick: result size, ‘occurrence’
> asPluralBasedOn: result size, ‘ ‘,  result printString.
> Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20190220/654d4f5b/attachment.html>

More information about the Pharo-users mailing list