[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: New i18n interface for KDE 4, second try
From: Nicolas Goutte <nicolasg () snafu ! de>
Date: 2005-10-30 14:47:12
Message-ID: 200510301546.23610.nicolasg () snafu ! de
[Download RAW message or body]
On Sunday 30 October 2005 14:40, Chusslove Illich wrote:
(...)
> QString("%1 %1").arg("foo").arg("bar")
>
> results in "foo bar", while
Ooh, I have not know this trap!
>
> QString("%1 %1").arg("foo", "bar")
>
> results in "foo foo".
(...)
> To further empower the template solution, we can also dispense with
> formatting .arg() methods of QString:
>
> QString::arg(int a, int fieldWidth = 0, ...)
>
> used like:
>
> i18n("Directory %1: %2 MB").arg(dir).arg(size, 5) // dangerous
>
> by defining few small standalone matching functions:
>
> QString qarg (int a, int fieldWidth = 0, ...) {
> return QString("%1").arg(a, fieldWidth, ...)
> }
>
> and using it in template call:
>
> i18n("Directory %1: %2 MB", dir, qarg(size, 5)) // safe
That is pretty much useless. If we go so far away from QString, we can
directly use QString::number, which is static. (That would be better than to
have QString-like arg functions but that do not work like QString::arg
functions.)
Have a nice day!
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic