Project

General

Profile

Actions

Feature #5264

open

Usage of Wt::WString::trn() throughout the Wt library

Added by Pavlo Zhernov about 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
09/16/2016
Due date:
% Done:

0%

Estimated time:

Description

There is an example of XML on Wt::WMessageResourceBundle Class Reference page which illustrates the usage of plural forms:

<?xml version="1.0" encoding="UTF-8"?>
  <messages nplurals="3" 
            plural="n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2">

    <message id="file">
      <plural case="0">{1} plik</plural>
      <plural case="1">{1} pliki</plural>
      <plural case="2">{1} pliko'w</plural>
    </message>

  </messages>

When I tried to use this example with auth_strings.xml file, I got:

[error] "WMessageResources: Error reading auth_strings.xml: at character 82: could not parse xhtml entity"

because of ampersand characters.

So there should be

&amp;&amp;

instead of

&&

in the "plural" argument of "messages" tag.

Further I have found out that my plural forms for the following keys do not work (English strings are shown instead):

  1. "Wt.Auth.remember-me-info.days"
  2. "Wt.Auth.remember-me-info.weeks"
  3. "Wt.Auth.user-name-tooshort"
  4. "Wt.Auth.password-tooshort"

This is because Wt::Wstring::tr() function is used instead of Wt::WString::trn() in:

  1. src/Wt/Auth/AuthModel.C:54
  2. src/Wt/Auth/AuthModel.C:56
  3. src/Wt/Auth/RegistrationModel.C:177
  4. I have not found "Wt.Auth.password-tooshort" in the source code at all

Also the following keys in wt.xml are based on English:

"Wt.WDateTime.second"

"Wt.WDateTime.seconds"

"Wt.WDateTime.minute"

"Wt.WDateTime.minutes"

"Wt.WDateTime.hour"

"Wt.WDateTime.hours"

"Wt.WDateTime.day"

"Wt.WDateTime.days"

"Wt.WDateTime.week"

"Wt.WDateTime.weeks"

"Wt.WDateTime.month"

"Wt.WDateTime.months"

"Wt.WDateTime.year"

"Wt.WDateTime.years"

The following function does not need to compare seconds, ..., years with 1:

WString WDateTime::timeTo(const WDateTime& other, int minValue) const;

It should use Wt::WString::trn() intead to make it possible to use three different forms in wt.xml using "plural" tags.

By the way, here is translation rules for plurals for several languages that one can use at the top of his/her xml file (remember to change each

&

into

&amp;

):

http://doc.qt.io/qt-5/i18n-plural-rules.html

No data to display

Actions

Also available in: Atom PDF