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

List:       kde-devel
Subject:    Re: delay i18n arg replacement
From:       Milian Wolff <mail () milianw ! de>
Date:       2015-01-19 22:00:55
Message-ID: 4564122.Ra6OEn05eK () minime
[Download RAW message or body]

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 <<
[prev in list] [next in list] [prev in thread] [next in thread] 

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