Feature: Showing units along with labels

Thiago Macieira thiago at macieira.org
Sun Mar 9 16:58:36 PDT 2014


Em dom 09 mar 2014, às 08:26:36, Dirk Hohndel escreveu:
> +               if (prefs.text_label_with_units) {
> +                       ui.airTempLabel->setText(QApplication::translate("Ma
> inTab", +                                               &(*(std::string("Air
> temp") + +                                                               "
> [" +
> +                                                               *(get_temp_
> unit().toStdString().rbegin()) +
> +                                                               "]").begin(
> )), +                                               0,
> QApplication::UnicodeUTF8)); +
> 
> this breaks translation - the strings are parsed by a tool in order to
> be collected for translation - nowhere here is the final string
> accessible to the tool, so when at run time the string is assembled, it
> won't be found in the translation database. It's a much better idea to
> concatenate two translated strings:

Rule 1 of translated UI: never concatenate strings.

Please do it like this:

if (prefs.text_label_with_units) {
        ui.airTempLabel->setText(QApplication::translate("MainTab", "Air temp 
[%1]").arg(getTempUnit()));
	[...]
} else {
	[...]
}

Note I removed the useless 0 and QApplication::UnicodeUTF8 arguments. They're 
redundant in that position. You can add them so they code is similar to the 
else branch if you want.

> Also, that whole painful conversion to std::string seems rather awkward
> and unnecessary. Simply use QString.

It's more than awkward and unnecessary. It's inefficient and downright wrong for 
any unit containing the degree symbol (°).

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358



More information about the subsurface mailing list