[open-ils-commits] r8164 - in trunk/Open-ILS/src: c-apps sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 6 17:31:12 EST 2007
Author: miker
Date: 2007-12-06 17:11:22 -0500 (Thu, 06 Dec 2007)
New Revision: 8164
Modified:
trunk/Open-ILS/src/c-apps/oils_cstore.c
trunk/Open-ILS/src/sql/Pg/002.functions.config.sql
Log:
fixing i18n infrastructure in the DB
Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-12-06 21:36:41 UTC (rev 8163)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c 2007-12-06 22:11:22 UTC (rev 8164)
@@ -1809,7 +1809,7 @@
char* pkey = osrfHashGet(idlClass, "primarykey");
char* tname = osrfHashGet(idlClass, "tablename");
- buffer_fadd(select_buf, " oils_i18n_xlate('%s.%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, __column, cname, pkey, locale, __column);
+ buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, __column, pkey, cname, pkey, locale, __column);
} else {
buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, __column, __column);
}
@@ -1853,7 +1853,7 @@
char* pkey = osrfHashGet(idlClass, "primarykey");
char* tname = osrfHashGet(idlClass, "tablename");
- buffer_fadd(select_buf, " oils_i18n_xlate('%s.%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, cname, pkey, locale, __alias);
+ buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, __alias);
} else {
buffer_fadd(select_buf, " \"%s\".%s AS \"%s\"", cname, fname, __alias);
}
@@ -2214,7 +2214,7 @@
char* pkey = osrfHashGet(idlClass, "primarykey");
char* tname = osrfHashGet(idlClass, "tablename");
- buffer_fadd(select_buf, " oils_i18n_xlate('%s.%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, cname, pkey, locale, fname);
+ buffer_fadd(select_buf, " oils_i18n_xlate('%s', '%s', '%s', \"%s\".%s::TEXT, '%s') AS \"%s\"", tname, fname, pkey, cname, pkey, locale, fname);
} else {
buffer_fadd(select_buf, " \"%s\".%s", cname, fname);
}
Modified: trunk/Open-ILS/src/sql/Pg/002.functions.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.functions.config.sql 2007-12-06 21:36:41 UTC (rev 8163)
+++ trunk/Open-ILS/src/sql/Pg/002.functions.config.sql 2007-12-06 22:11:22 UTC (rev 8164)
@@ -40,11 +40,13 @@
*/
-CREATE OR REPLACE FUNCTION oils_i18n_xlate ( keyfield TEXT, keyvalue TEXT, raw_locale TEXT ) RETURNS TEXT AS $func$
+CREATE OR REPLACE FUNCTION oils_i18n_xlate ( keytable TEXT, keycol TEXT, identcol TEXT, keyvalue TEXT, raw_locale TEXT ) RETURNS TEXT AS $func$
DECLARE
locale TEXT := LOWER( REGEXP_REPLACE( REGEXP_REPLACE( raw_locale, E'[;, ].+$', '' ), E'-', '_', 'g' ) );
language TEXT := REGEXP_REPLACE( locale, E'_.+$', '' );
result config.i18n_core%ROWTYPE;
+ fallback TEXT;
+ keyfield TEXT := keytable || '.' || keycol;
BEGIN
-- Try the full locale
@@ -65,7 +67,13 @@
-- Fall back to the string we passed in in the first place
IF NOT FOUND THEN
- RETURN keyvalue;
+ EXECUTE
+ 'SELECT ' ||
+ keycol ||
+ ' FROM ' || keytable ||
+ ' WHERE ' || identcol || ' = ' || quote_literal(keyvalue)
+ INTO fallback;
+ RETURN fallback;
END IF;
RETURN result.string;
More information about the open-ils-commits
mailing list