You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Geoff Callender <ge...@gmail.com> on 2015/04/20 11:09:04 UTC
Localise a page link
I'm generating a page link with PageRenderLinkSource. No problem. Now I'd like to generate it for a specific locale.
I've tried using LocalizationSetter#setNonPersistentLocaleFromLocaleName immediately before PageRenderLinkSource#createPageRenderLinkWithContext , but it has no effect.
The aim is to produce a PDF in a specific language with PhantomJS. PhantomJS is run in a command, with my page URL as a parameter. Without the locale in the URL, the page prints in the default language.
Geoff
Re: Localise a page link
Posted by Geoff Callender <ge...@gmail.com>.
I've found an answer. It involves the persistent locale, whereas I'd been trying to do it with ThreadLocale.
// Save the current locale.
Locale localeSnapshot = locale;
// Temporarily set the persistent locale.
localizationSetter.setLocaleFromLocaleName(targetLocale.toString());
// Generate the page link.
...
// Restore the current locale.
localizationSetter.setLocaleFromLocaleName(localeSnapshot.toString());
On 20 Apr 2015, at 7:09 pm, Geoff Callender <ge...@gmail.com> wrote:
> I'm generating a page link with PageRenderLinkSource. No problem. Now I'd like to generate it for a specific locale.
>
> I've tried using LocalizationSetter#setNonPersistentLocaleFromLocaleName immediately before PageRenderLinkSource#createPageRenderLinkWithContext , but it has no effect.
>
> The aim is to produce a PDF in a specific language with PhantomJS. PhantomJS is run in a command, with my page URL as a parameter. Without the locale in the URL, the page prints in the default language.
>
> Geoff
>
Re: Localise a page link
Posted by Lance Java <la...@googlemail.com>.
I think you can @Inject ThreadLocale and call ThreadLocale.setLocale(xxx).
On 20 Apr 2015 10:09, "Geoff Callender" <
geoff.callender.jumpstart@gmail.com> wrote:
> I'm generating a page link with PageRenderLinkSource. No problem. Now I'd
> like to generate it for a specific locale.
>
> I've tried using LocalizationSetter#setNonPersistentLocaleFromLocaleName
> immediately before PageRenderLinkSource#createPageRenderLinkWithContext ,
> but it has no effect.
>
> The aim is to produce a PDF in a specific language with PhantomJS.
> PhantomJS is run in a command, with my page URL as a parameter. Without the
> locale in the URL, the page prints in the default language.
>
> Geoff
>
>