RE: Localizing stored functions by replacing placeholders in their body

From: Kevin Brannen <KBrannen(at)efji(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: RE: Localizing stored functions by replacing placeholders in their body
Date: 2021-03-02 23:57:09
Message-ID: SN6PR19MB23517A8E74B65DA762FBC307A4999@SN6PR19MB2351.namprd19.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----Original Message-----
From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Sent: Tuesday, March 2, 2021 2:19 PM
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Localizing stored functions by replacing placeholders in their body

On 2021-Mar-02, Alexander Farber wrote:

> CREATE OR REPLACE FUNCTION localize_hello()
> RETURNS text AS
> $func$
> SELECT '$(hello)';
> $func$ LANGUAGE sql IMMUTABLE;

I'm not sure this is a great approach to in-database translations: you have one function per string, which is cumbersome, bloated and probably slow...

-------------------

I would agree with Alvaro and take it a step further. Perhaps you didn't do it this way, but many applications are split with back-end code to get & generate data while a set of templates is used to produce the result (HTML or whatever) the user sees. Many times these "template systems/toolkits" have I18N built into them in some way. If that's possible for you, I'd suggest investigating that. Overall, this seems more like an application problem and not a DB problem.

HTH,
Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential information. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or attached to this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify us by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them to disk. Thank you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2021-03-03 08:08:29 Re: Localizing stored functions by replacing placeholders in their body
Previous Message Asaf Flescher 2021-03-02 23:15:43 Re: Locks in creating a partition in CREATE TABLE vs ALTER TABLE