From kde-devel Mon Jan 19 22:00:55 2015 From: Milian Wolff Date: Mon, 19 Jan 2015 22:00:55 +0000 To: kde-devel Subject: Re: delay i18n arg replacement Message-Id: <4564122.Ra6OEn05eK () minime> X-MARC-Message: https://marc.info/?l=kde-devel&m=142170495203218 On Monday 19 January 2015 14:42:13 Chusslove Illich wrote: > > [: 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). Thanks! Exactly what I needed. Bye -- Milian Wolff mail@milianw.de http://milianw.de >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<