1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
-- ==============================================================
-- GNUmed database schema change script
--
-- License: GPL v2 or later
-- Author: karsten.hilbert@gmx.net
--
-- ==============================================================
-- $Id: v11-i18n-tx_or_null.sql,v 1.1 2009-06-04 17:48:10 ncq Exp $
-- $Revision: 1.1 $
-- --------------------------------------------------------------
\set ON_ERROR_STOP 1
\set check_function_bodies 1
--set default_transaction_read_only to off;
-- =============================================
create or replace function i18n.tx_or_null(text, text)
returns text
language 'plpgsql'
security definer
as '
DECLARE
_orig alias for $1;
_lang alias for $2;
trans_str text;
BEGIN
select into trans_str trans from i18n.translations where lang = _lang and orig = _orig;
if not found then
return null;
end if;
return trans_str;
END;
';
comment on function i18n.tx_or_null(text, text) is
'will return either the translation into language <text> (2nd argument) or null';
-- =============================================
create or replace function i18n.tx_or_null(text)
returns text
language sql
as 'select i18n.tx_or_null($1, i18n.get_curr_lang())';
comment on function i18n.tx_or_null(text) is
'will return either the translation into i18n.curr_lang.lang for the current user or null';
-- --------------------------------------------------------------
select gm.log_script_insertion('$RCSfile: v11-i18n-tx_or_null.sql,v $', '$Revision: 1.1 $');
-- ==============================================================
-- $Log: v11-i18n-tx_or_null.sql,v $
-- Revision 1.1 2009-06-04 17:48:10 ncq
-- - first version
--
--
|