K
K
Karen Kratyan2013-06-19 15:25:13
PHP
Karen Kratyan, 2013-06-19 15:25:13

Correct localization in Modx when dealing with plurals?

How to do localization in modx when working with plurals?
1, 21, 31… day
2, 3, 4… days
5, 6, 7… days
So far, just this snippet idea:

return (n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)

and use inside the translation value:
 

By the way, there is selecta filter, but I have not tried it. Can it be used instead of a complex design?
Update :

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tiamorphis, 2013-12-26
@kratkar

The repository has the Units package - exactly what you need in this case.

B
bezumkin, 2013-06-22
@bezumkin

If you need to display dates, it's easier to take a ready-made .
If you're not interested, you can look at the source .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question