Problem formulation

Problem formulation

написао/ла Bojan Milosavljević -
Број одговора: 0

I think there are many of us using Slavic and some other languages who have noticed the problem related to grammar insensitivity of multilingual support. I have been so dissatisfied with this that I have created the procedure handling the problem in a pretty general manner. The code and the corresponding language packs will be available at CVS's contrib/grammar_aware folder.

This topic is for discussion on that matter.

Here is the illustration: Adding a new $a has the same form in English no matter what the gender and the case (declination) of an activity being hold in $a variable are.

But in many other languages that is not the case! So, in Serbian: adding=dodavanje new=nov;nova;novo, depending on gender, of something that follows, lesson=lekcija for instance.

Thus adding a new lesson would be dodavanje nova lekcija if we don't care about declination, but should be dodavanje nove lekcije in a proper form.

So, as we don't know in advance what is stored in $a, firstly we have to explore the gender of an activity $a and then to apply a proper case (Genitive Case in this example).

So this is translated in my grammar-sensitive language packs as follows:
$string['addinganew'] = 'Dodavanje nov<eval> sr_lg_gender_ext(sr_lg_male_female('$a'),'og','e','og') . ' ' . sr_lg_genitive('$a')</eval>';

According to gender detected by sr_lg_male_female('$a') , a proper extension (set in the Genitive Case) is determined and then concatenated with Genitive-Case form of an activity name, being stored in $a.

Another illustration: In English, eg. messages is the plural form of message no matter the count of messages. But, this is not true in many other languages! So, the same in Serbian would be 1 poruka, 2,3,4 poruke, but 5,6,...,10 poruka, 11,...,20 poruka, 21 poruka, 22,...,24 poruke, 25,...,30 poruka etc. There are actually 4 cases:

  1. singular form, used for numbers being pronounced in sequences and ending with 1 as well, eg. twenty-one, thirty-one etc.
  2. for numbers being pronounced in sequences and ending with 2 through 4
  3. for numbers being pronounced in sequences and ending with 5 through 9 and 0
  4. for numbers from 11 through 19 with particular names, such us eleven, twelve etc. and adding up to the Case 3

If you 're still there, you are probably interested how all this is organized. Here is how – get_string function is modified in the <moodle root>/lib/moodlelib.php:

eval_get_string($resultstring) , instead of just $resultstring,

is returned if the file from language pack other than English is found.

eval_get_string is the function from the modified moodlelib.php, performing an additional code evaluation of functions handling language-specific grammar.

All these functions reside in the file langfun.php of the language-pack folder (sr_lg_utf8 here).

So, the corresponding file langfun.php has to be included (its code executed) once.

A translator is also a programmer now.

As only admins can see these language strings, they are probably those translators / programmers.

I am aware of the claims regarding security threats that are likely to come. That 's why I have restricted the usage of ';' and so on, but since the admins are already the only persons being able to see these language strings, I am daring enough to use this. Seeing grammar errors on the site of an educational institution is in my opinion far more threat to the institution than a security threat like this!