[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: delay i18n arg replacement
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2015-01-19 13:42:13
Message-ID: 201501191442.13355.caslav.ilic () gmx ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


> [: Milian Wolff :]
> Do I really need to store I18N_NOOP2_NOSTRIP and use that with
>
>   i18nc(asdf.context, asdf.translatedString, foo, bar)
>
> then? Or is there a better way, where it would be enough to store a
> QString in my static data structure? Or is this not possible b/c the
> translation might be scripted or something like that?

You could use ki18n* series of functions, which return KLocalizedString,
which is a "non-finalized" translation. To construct:

  asdf.translatedString = ki18nc("some context", "some text %1 (%2)");

and later to substitute arguments and get QString:

  asdf.translatedString.subs(foo).subs(bar).toString()

The actual translation lookup and argument substitution all happen in
toString and in one pass, so this works as expected wrt. early construction
(e.g. before KLocalizedString::setApplicationDomain is called) and wrt.
arguments themselves containing placeholder-like sequences (e.g. if foo
above contained %1).

-- 
Chusslove Illich (Часлав Илић)

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic