📜 ⬆️ ⬇️

Super-simple plugin, correctly declining the word "comment".

Once upon a time I read some article about the development of civilizations. There was a curious detail about the account. The author of the article claimed that the primitive man considered this: one, two, and so to some limit of a countable set, a lot. That is, he could count to some limited limit, and everything that is greater than this countable set did not fit into his brains and was simply called “a lot”. And he gave arguments for the fact that in Russian (as in some others) there are still traces of this division, for example:



That is, the countable set of the ancient Slavs ended in the region of four.
')
Actually, it was the lyrics.

When setting up a wordpress blog, I encountered the following problem: it is impossible to adjust the normal declination under Russian (since I am not a humanist, I can’t vouch for the accuracy of using the term :) noun “comment”. That is, they wrote 1 comment, 2 comments, or 5 comments on the post.

In English, this case is easier. 0 comments, 1 comment, 2 and more comments. This is how the standard comments_number function works in the wp-includes / comment-tempate.php file. It takes only four arguments - a formula for displaying zero comments, one comment, “many” comments, and also the deprecated flag.

But I am writing in Russian, and, accordingly, I have a different situation. So. In order to properly incline the word "comments" we need to handle the following situations:


To solve this, I wrote this simple plugin .

The plugin is installed very simply - unzip, copy to the wp-content / plugins folder, activate it in the admin area. Tested on wordpress versions 2.3.3, 2.5.1.
He has no settings, so he stupidly displays "23 comments", "31 comments" and so on.

Actually, for the time being, I see no reason to modify it, since I am completely satisfied with its functionality. In principle, you can also add a number converter to words, so that the verbal description of the number of comments is completely, but I think this is not the best option - it’s much more convenient to understand the number with a glance at the number than to read the whole line to find out four hundred eighty nine comments.

Crosspost on my blog.

Source: https://habr.com/ru/post/26503/


All Articles