← Back to team overview

mahara-contributors team mailing list archive

[Bug 1958085] Re: Translation issue when there is more than one plural form

 

The existing code is using ['post'] and ['posts'], rather than
['nposts'] which has the array of options for plurals.

It's easy enough to change this to use ['nposts'], and when I do this,
it picks up the correct plural form.

However, the array options contain a %s variable for including the
number, or a hard coded '1' or 'Jeden' for the singular. With our
paginator, the digit in front of the plural form is calculated and
rendered separately to the string.

This means that when we use the plural form ['nposts'], two numbers are
being rendered, e.g. '2 2 posts'

We could remove the number from the plural string options, and leave our
paginator as it is. With this option, we would have to update all
langpacks to make sure they don't include the number in their plural
forms.

Or, we could update the paginator to not render the first number in
front of the string, and instead allow the string to render the number
we pass through to it. That would mean we'd need to ensure we used the
plural string form for all instances of the paginator, as well as
updating the paginator(s)

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: mahara-contributors
https://bugs.launchpad.net/bugs/1958085

Title:
  Translation issue when there is more than one plural form

Status in Mahara:
  In Progress

Bug description:
  For example, Czech has two plural forms that have been translated, but
  only the first one is (1) picked up in Mahara no matter how many posts
  there are in a journal for example, where all plural forms have been
  translated. Plural forms were implemented in bug #901051.

  More context information is available at http://www.gnu.org/savannah-
  checkouts/gnu/gettext/manual/html_node/Plural-forms.html and
  https://git.mahara.org/mahara/mahara/-/blob/master/htdocs/lang/en.utf8/langconfig.php#L50

  The plural rules for Czech: "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n":
  i.e. use plural 1 for 2-4 and plural 2 for 0, 5 and more.

  langpacks/cs.utf8/artefact/blog/lang/cs.utf8/artefact.blog.php

  $string['nposts'] = array(

                   0 => 'Jeden příspěvek',
                   1 => '%s příspěvky,',
                   2 => '%s příspěvků'
  );

  $string['youhavenblog'] = array(

                   0 => 'Máte jeden deník.',
                   1 => 'Máte %d deníky.',
                   2 => 'Máte %d deníků.'

  In Mahara we have:
  ---
  $string['pluralrule'] = '(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2';
  $string['pluralfunction'] = 'plural_cs_utf8';
  function plural_cs_utf8($n) {
      return ($n==1) ? 0 : ($n>=2 && $n<=4) ? 1 : 2;
  }
  ---

  which indicates that it should support plural forms, but it doesn't.

  To replicate:

  1. Install the Czech lang pack (via CLI). It's code is 'cs'.
  2. Create 2 journal entries and check the lang string for the number of journal entries in that journal. It should say 'příspěvky' but it says '2 příspěvků'.
  3. Create another 3 entries so you have 4 and check the lang string. It says 'příspěvků' correctly.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1958085/+subscriptions



References