Plurial

Hello,
a small code to facilitate the agreement in the plural of a text.
The idea is to send as a parameter a text (column or fixed) and a number in order to determine whether to put the text in the plural.

EDIT Revision 3
Deletion of the Criterion parameter
Automatic detection of number column type for number, boolean, text use

5 Likes

:star_struck::star_struck:

That’s perfect!

What about male and female words/variations in Latin languages as ours? Should be awesome too :face_with_hand_over_mouth:

2 Likes

Dude this is perfect. I said start a Notion page another day but may just redirect it to your forum profile.

1 Like

Hello @Lucas_Pires

Ah uhmmmm,
do you have an example of distinction between mr and mrs based on a number?

Thank you @ThinhDinh
But I saw your Notion for CSS page and I find it great, simple, clear and easy. So it’s rather the opposite :slight_smile:

1 Like

Merci @Manu.n, j’ai exactement eu ce dilemme du “pluriel” hier sur plusieurs champs où je ne savais pas comment faire qq chose de propre !
image

Bon, le seul pb, c’est que j’avais dit que je ne me penchais pas maintenant sur cette fonction YesCode (0 connaissance en JS, etc)…

Bonne journée

bonjour @AyS_0908
you can simply copy the code (fork function in replit)
If you need a helping hand.
Call me

Thanks @Manu.n.
Question about your code (sorry if it’s dummy, I am really at 0 level, even less, on this topic):

  • can we apply the code to multiple columns with words requiring the Plural to be managed?
  • or do we have to create 3 columns (if I understood well: date suivante /relscount || date suivante / titre || relscount) for each word?
    Thanks

uhmm
If you have several words in the same sentence: no problem, like my example:
Date{s} Suivante{s}

But if you have several columns, you must use a new YC column each time.

In my example I’m referring to a relation column, but you can for example use this function like this:

If you want to test, you can use my code:
place this link in the YC column
https://pluriel.manun2.repl.co/

EDIT
but it is also possible not to have a txt column, and to put the text directly in the YC column

2 Likes

Hi my friend,

I translated this code to English and had a bit of a different approach here.

Input: Number & Singular/Plural format of the text (e.g: teacher/teachers, shelf/shelves, watch/watches). This covers all the cases when it’s not simply just “s”.

Output: Number and the right unit text. (1 is singular, 0 and > 1 are plural)

If I recall right, @Darren_Murphy and @Robert_Petitto had been calling for this unit thing to be available for the math column/number column for so long.

5 Likes

If I can afford it.
I made a criterion, to be able to also use boolean values ​​like Count values
After, using the “/” as a marker can be “dangerous” like a “page 1/10” text suddenly it doesn’t work anymore.
But your script is fine too

1 Like

That’s a fair point. Maybe if it ever becomes a problem we switch to something no one ever uses like ♤ :laughing:

the {…} tag is a bit of a convention for replacement values

1 Like

Brilliant!

1 Like

Ultimately, it is easier to use 2 parameters for the text.
Singular
Plural

1 Like

Pfffffffff
As it is a good idea, Suddenly, I copied on you adding a flag to add the number. :stuck_out_tongue_winking_eye: :rofl:

1 Like

@Manu.n
But what if the plural isn’t just adding an “s”?

Eg.
woman > women
Foot > feet
Inch > inches

I add an optional parameter for the particular case

Maybe I’m missing something here, but isn’t this use case a bit of overkill?

I mean, this is trivial with just an if-then-else column and a template, so why resort to code? :thinking:

It is in fact a case of often encountered, it replaces 3 calculated columns (singular template, plural template, ifThen)