Feature #5264

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

Added by Pavlo Zhernov over 6 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


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>


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


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:















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





No data to display

Also available in: Atom PDF