Trying to do localization / pluralization with a lot of options. Translation file:

'teachers' => '{0} Ни одного преподавателя |{1} :count преподаватель |[2-4] :count преподавателя |[5-20] :count преподавателей |[21-24] :count преподавателя |[25-Inf] :count преподавателей' 

But strange happens. Call example:

 {{ Lang::choice('course.teachers', 0) }} {{ Lang::choice('course.teachers', 1) }} {{ Lang::choice('course.teachers', 2) }} {{ Lang::choice('course.teachers', 5) }} {{ Lang::choice('course.teachers', 16) }} {{ Lang::choice('course.teachers', 22) }} {{ Lang::choice('course.teachers', 46) }} {{ Lang::choice('course.teachers', 12) }} 

As a result, we have the following conclusion:

  - Ни одного преподавателя / все верно / - 1 преподаватель / все верно / - 2 преподавателя / все верно / - 5 преподавателей / все верно / - 16 преподавателя / ????????? / - 22 преподаватель / ????????? / - 46 преподавателя / ????????? / - 12 преподавателя / ????????? / 

What am I doing wrong? Or maybe some other way to solve the problem.

2 answers 2

Try this:

 'teachers' => '{0} Ни одного преподавателя |{1} :count преподаватель |[2,4] :count преподавателя |[5,20] :count преподавателей |[21,24] :count преподавателя |[25,*] :count преподавателей' 

    There is no point in this design. It is enough to specify three forms of the word -

     'teachers' => 'Преподавателей|Преподователь|Преподователя' 

    The order of forms could be confused because of its innate illiteracy. What is written above will not work correctly.

    PS: Called so

     trans_choice('messages.teachers', 10); 
    • Well, this gettext works this way, if you specify the number of word forms and the rules for their formation, but in laravel it did not work out for me - t1gor pm
    • At 5.7, at least it works (checked). Perhaps on earlier versions it was not for the Russian rule. You can look at \ vendor \ laravel \ framework \ src \ Illuminate \ Translation \ MessageSelector.php on your version. - Maxim Stepanov
    • Thanks, I will look - t1gor