On Tue, Jul 22, 2008 at 5:35 PM, Mike Rylander <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 22, 2008 at 2:40 PM, Dan Scott <[EMAIL PROTECTED]> wrote:
>> Hi Mike:
>>
>> The database location is good. Is there any reason you chose to go
>> with the "ll_ll" form for language/region in the code field, rather
>> than the "ll-LL" form currently used for translations? The latter form
>> is also used by Dojo, which would be handy for locazing dates, times,
>> and currencies.
>
> The ll_ll form is simply normalized to avoid any case-based confusion.
>  I'll have to look through the code to make sure there are no
> assumptions of _ instead of -, but we can change to '-' notation.  If
> we provide (which we will) an interface for creating supported
> locales, then I suppose I could drop the case folding as well.
>
> I normalize to "lower and  _" in the core i18n stored proc and the
> split on _ to find generalizations, but I can remove the normalization
> if we can accept the constraint (human-imposed) of "don't shoot
> yourself in the foot -- use exact matches for local strings" ... which
> I suppose we can. :)

After supposing for a few days, here are 2 patches which remove the
normalization (there was less than I thought) sprinkled throughout the
code.  No more lowercasing, but we do change '_' to '-' in the core
stored procedure that does the translated value lookup.

With these patches in place (they're not yet), it's required that ALL
locales be assembled in the ll-LL format (that's not strictly true ...
there's just no fudge factor in locale case anymore). Eyeballs
apreciated, since they touch python and java in addition to "my"
areas.

-- 
Mike Rylander
 | VP, Research and Design
 | Equinox Software, Inc. / The Evergreen Experts
 | phone: 1-877-OPEN-ILS (673-6457)
 | email: [EMAIL PROTECTED]
 | web: http://www.esilibrary.com
Index: Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- Open-ILS/src/sql/Pg/002.schema.config.sql	(revision 10145)
+++ Open-ILS/src/sql/Pg/002.schema.config.sql	(working copy)
@@ -445,7 +445,7 @@
 
 CREATE TABLE config.i18n_locale (
     code        TEXT    PRIMARY KEY,
-    marc_code   TEXT    NOT NULL REFERENCES config.language_map (code),
+    marc_code   TEXT    NOT NULL REFERENCES config.language_map (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
     name        TEXT    UNIQUE NOT NULL,
     description TEXT
 );
@@ -454,7 +454,7 @@
     id              BIGSERIAL   PRIMARY KEY,
     fq_field        TEXT        NOT NULL,
     identity_value  TEXT        NOT NULL,
-    translation     TEXT        NOT NULL    REFERENCES config.i18n_locale (code),
+    translation     TEXT        NOT NULL    REFERENCES config.i18n_locale (code) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
     string          TEXT        NOT NULL
 );
 
Index: Open-ILS/src/sql/Pg/002.functions.config.sql
===================================================================
--- Open-ILS/src/sql/Pg/002.functions.config.sql	(revision 10145)
+++ Open-ILS/src/sql/Pg/002.functions.config.sql	(working copy)
@@ -68,8 +68,8 @@
 
 CREATE OR REPLACE FUNCTION oils_i18n_xlate ( keytable TEXT, keyclass 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'_.+$', '' );
+    locale      TEXT := REGEXP_REPLACE( REGEXP_REPLACE( raw_locale, E'[;, ].+$', '' ), E'_', '-', 'g' );
+    language    TEXT := REGEXP_REPLACE( locale, E'-.+$', '' );
     result      config.i18n_core%ROWTYPE;
     fallback    TEXT;
     keyfield    TEXT := keyclass || '.' || keycol;
Index: Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- Open-ILS/src/sql/Pg/950.data.seed-values.sql	(revision 10145)
+++ Open-ILS/src/sql/Pg/950.data.seed-values.sql	(working copy)
@@ -695,15 +695,15 @@
 
 -- available locales
 INSERT INTO config.i18n_locale (code,marc_code,name,description)
-    VALUES ('en_us','eng',oils_i18n_gettext('American English'),oils_i18n_gettext('American English'));
+    VALUES ('en-US','eng',oils_i18n_gettext('American English'),oils_i18n_gettext('American English'));
 INSERT INTO config.i18n_locale (code,marc_code,name,description)
-    VALUES ('en_ca','eng',oils_i18n_gettext('Canadian English'),oils_i18n_gettext('Canadian English'));
+    VALUES ('en-CA','eng',oils_i18n_gettext('Canadian English'),oils_i18n_gettext('Canadian English'));
 INSERT INTO config.i18n_locale (code,marc_code,name,description)
-    VALUES ('fr_ca','fre',oils_i18n_gettext('Canadian Fench'),oils_i18n_gettext('Canadian French'));
+    VALUES ('fr-CA','fre',oils_i18n_gettext('Canadian Fench'),oils_i18n_gettext('Canadian French'));
 INSERT INTO config.i18n_locale (code,marc_code,name,description)
-    VALUES ('es_us','spa',oils_i18n_gettext('American Spanish'),oils_i18n_gettext('American Spanish'));
+    VALUES ('es-US','spa',oils_i18n_gettext('American Spanish'),oils_i18n_gettext('American Spanish'));
 INSERT INTO config.i18n_locale (code,marc_code,name,description)
-    VALUES ('es_mx','spa',oils_i18n_gettext('Mexican Spanish'),oils_i18n_gettext('Mexican Spanish'));
+    VALUES ('es-MX','spa',oils_i18n_gettext('Mexican Spanish'),oils_i18n_gettext('Mexican Spanish'));
 
 
 --005.schema.actors.sql:
Index: Open-ILS/web/conify/global/admin.js
===================================================================
--- Open-ILS/web/conify/global/admin.js	(revision 10145)
+++ Open-ILS/web/conify/global/admin.js	(working copy)
@@ -1,7 +1,7 @@
 var djConfig = { parseOnLoad : true };
 
 if (location.href.match(/^.*conify\/(.+)\/global.*$/, "$1")) {
-	var _url_locale = location.href.replace(/^.*conify\/(.+)\/global.*$/, "$1").toLowerCase().replace(/_/,'-','g');
+	var _url_locale = location.href.replace(/^.*conify\/(.+)\/global.*$/, "$1").replace(/_/,'-','g');
 
 	if (_url_locale) djConfig.locale = _url_locale;
 
Index: Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js
===================================================================
--- Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js	(revision 10145)
+++ Open-ILS/web/js/dojo/openils/widget/TranslatorPopup.js	(working copy)
@@ -102,11 +102,11 @@
 						{ store:openils.I18N.localeStore,
 						  searchAttr:'locale',
 						  labelAttr:'label',
-						  lowercase:true,
+						  lowercase:false,
 						  required:true,
 						  id:'locale_' + trans_id,
 						  value: trans_obj.translation(),
-						  invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us',
+						  invalidMessage:'Specify locale as {languageCode}-{countryCode}, as in en-US',
 						  regExp:'[a-z_]+'
 						}
 					);
@@ -147,9 +147,9 @@
 					  searchAttr:'locale',
 					  labelAttr:'label',
 					  id:'i18n_new_locale_' + this._targetObject.classname + '.' + this.field + this.unique,
-					  lowercase:true,
+					  lowercase:false,
 					  required:true,
-					  invalidMessage:'Specify locale as {languageCode}_{countryCode}, like en_us',
+					  invalidMessage:'Specify locale as {languageCode}_{countryCode}, as in en-US',
 					  regExp:'[a-z_]+'
 					}
 				);
Index: src/java/org/opensrf/Session.java
===================================================================
--- src/java/org/opensrf/Session.java	(revision 1372)
+++ src/java/org/opensrf/Session.java	(working copy)
@@ -27,7 +27,7 @@
     /** Session locale */
     protected String locale;
     /** Default session locale */
-    protected static String defaultLocale = "en_US";
+    protected static String defaultLocale = "en-US";
 
     /** 
      * The thread is used to link messages to a given session. 
Index: src/python/osrf/ses.py
===================================================================
--- src/python/osrf/ses.py	(revision 1372)
+++ src/python/osrf/ses.py	(working copy)
@@ -84,7 +84,7 @@
 class ClientSession(Session):
     """Client session object.  Use this to make server requests."""
 
-    def __init__(self, service, locale='en_US'):
+    def __init__(self, service, locale='en-US'):
         
         # call superclass constructor
         Session.__init__(self)
Index: src/javascript/DojoSRF.js
===================================================================
--- src/javascript/DojoSRF.js	(revision 1372)
+++ src/javascript/DojoSRF.js	(working copy)
@@ -17,5 +17,5 @@
 		return this.session_cache[app];
 	}
 
-	OpenSRF.locale = dojo.config.locale || (dojo.isIE ? navigator.userLanguage : navigator.language).toLowerCase();
+	OpenSRF.locale = dojo.config.locale || dojo.isIE ? navigator.userLanguage : navigator.language;
 }

Reply via email to