Plural support in Qt

Plural support allows linguistically correct localization of strings with numbers that indicate amount. This brings quality improvements for 17 languages in Symbian, such as Arabic, Czech and Russian. These languages use more than one grammatical plural form depending on the value of the parameter.

Plural support uses the special parameter %Ln, which makes it possible to create several translations for one string. When before two separate logical names would have been needed for singular ("1 message") and plural ("4 messages"), now you only need to create one logical name. Example:

  • Engineering English:

    • %Ln messages

  • English:

    • %Ln message (In device: "1 message")

    • %Ln messages (In device: "0 messages", "2 messages", "58 messages" etc.)

  • French:

    • %Ln message (In device: "0 message", "1 message")

    • %Ln messages (In device: "2 messages", "58 messages" etc.)

  • Russian:

    • %Ln сообщение (In device: "1 сообщение")

    • %Ln сообщения (In device: "2 сообщения", "23 сообщения" etc.)

    • %Ln сообщений (In device: "5 сообщений", "58 сообщений" etc.)

  • Plural support reduces the number of text IDs needed:

    • One text value "%Ln new messages" is enough in Qt instead of “1 new message” and “%N new messages” required in Avkon

  • Plural support allows the correct number of localizations for those languages with no plural or several plurals:

    • Chinese translator creates 1 translation (same form of the noun is used with all numbers)

    • Finnish translator creates 2 translations (one form for "1" and one for other numbers)

    • French translator creates 2 translations (one form for "0" or "1" and one for other numbers)

    • Polish translator creates 3 translations (one form for "1", another for numbers 2-4, 22-24, 32-34 etc., a third form for other numbers)

  • Use parameter %Ln to enable plural support

    • %Ln new messages

    • Alarm snoozed for %Ln minutes

    • %Ln callers on lines %L1 and %L2 (Note: only "callers" requires plural support).

    • %Ln new voice messages on line %L1 (Note: Only "new voice messages" requires plural support).

  • You should use %L1, %L2 etc. to display all other numerical parameter values. Examples of cases where plural support is not needed:

    • Deleting template %L1 of %L2

    • Page %L1

    • Group %L1

    • %Ln callers on lines %L1 and %L2 ("%Ln callers" requires plural support, but "lines %L1 and %L2" does not.)

  • Note that plural support can only be used with parameter values that are positive integers, and it is only available for one parameter %Ln at a time. This means that if a text value contains two parameters indicating amount that otherwise would require different grammatical plural forms, plural support cannot be used. Instead, you need to create four separate text IDs as shown in the following example:

    • %L1 file, %L2 folder

    • %L1 file, %L2 folders

    • %L1 files, %L2 folder

    • %L1 files, %L2 folders

Not all numerical values need plural support (such as ordinal numbers, for example: "Call on line %L1").

Zero and none

If a parameter can have multiple values and one of them is zero, plural support covers the issue. In that case, only one string (for example, "%Ln messages") is needed. However, in some situations the user needs to know that there are for example no messages or that the search found no results.

Typically, this kind of text is displayed as a placeholder when an inbox, search result field or playlist is empty. In this case a separate string with no parameters should be used:

  • No messages

  • No results

  • (no videos)

  • (no bookmarks)