Pluralising messages or choosing word alternatives
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
Maybe you can use the conditional syntax of expandMacros. On Wed, Feb 20, 2019, 18:08 Tim Mackinnon <tim@testit.works> wrote:
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
Why not use the condition macro so you have a single string literal, that in the future could be used for translation? E.g. | 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@testit.works>) escribió:
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
Some great suggestions here guys - I had forgotten there were conditionals in expandMacros⦠that is the better solution. Although I do kind of think that something on OrderedCollection like: chooseBasedOn: count ^self at: ((count max: 1) min: self size) Would be a nice general solution for other things (Iâm kind of suprised there isnât something like that there)
On 20 Feb 2019, at 21:21, Esteban Maringolo <emaringolo@gmail.com> wrote:
Why not use the condition macro so you have a single string literal, that in the future could be used for translation?
E.g. | 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@testit.works>) escribió: 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 <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
You should have a look at what Seaside has. Like Integer>>#pluralize:with: But also the class GRInflector that understand more about English than I do ;-)
On 20 Feb 2019, at 22:07, Tim Mackinnon <tim@testit.works> wrote:
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
These days we are supposed to think about internationalisation and localisation. The rather elderly and inadequate '<1P> foobar<2?:s>' expandMacrosWith: n with: n = 1 works fine for English, but when you switch to '<1P> foobar<2?:s>' translated expandMacrosWith: n with: n = 1 you run into the problem that there are languages, such as Hebrew and Modern Standard Arabic, with a dual number, so that you need to distinguish 1, 2, >2 cases. Then there are the oddball languages with a "paucal" number. Generally it is better to rephrase the text, 'Number of foobars = <1P>' expandMacrosWith: n. On Thu, 21 Feb 2019 at 10:08, Tim Mackinnon <tim@testit.works> wrote:
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
participants (5)
-
Esteban Maringolo -
Gabriel Cotelli -
Richard O'Keefe -
Sven Van Caekenberghe -
Tim Mackinnon