Index: openacs-4/packages/acs-lang/acs-lang.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/acs-lang.info,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/acs-lang/acs-lang.info 29 Oct 2002 08:08:01 -0000 1.15
+++ openacs-4/packages/acs-lang/acs-lang.info 3 Dec 2002 17:26:22 -0000 1.16
@@ -35,6 +35,7 @@
+
@@ -44,6 +45,7 @@
+
@@ -56,7 +58,7 @@
-
+
@@ -77,6 +79,11 @@
+
+
+
+
+
@@ -103,9 +110,14 @@
+
+
-
+
+
+
+
@@ -139,9 +151,6 @@
-
-
-
Index: openacs-4/packages/acs-lang/sql/oracle/ad-locales.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/oracle/ad-locales.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/acs-lang/sql/oracle/ad-locales.sql 15 Nov 2002 15:08:46 -0000 1.6
+++ openacs-4/packages/acs-lang/sql/oracle/ad-locales.sql 3 Dec 2002 17:26:34 -0000 1.7
@@ -114,10 +114,24 @@
create table ad_locale_user_prefs (
user_id integer
- primary key
+ constraint ad_locale_user_prefs_user_fk
references users (user_id),
locale varchar2(30) not null
constraint
- trb_language_preference_lid_fk
- references ad_locales (locale)
+ ad_locale_user_prefs_locale_fk
+ references ad_locales (locale),
+ package_id integer
+ constraint ad_locale_user_prefs_pid_fk
+ references apm_packages(package_id) on delete cascade
);
+
+-- primary key should be package_id and user_id
+create table user_timezone_pref (
+ user_id integer
+ constraint user_timezone_pref_pk
+ primary key
+ constraint user_timezone_pref_user_fk
+ references users (user_id),
+ timezone integer
+
+)
\ No newline at end of file
Index: openacs-4/packages/acs-lang/sql/oracle/message-audit.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/oracle/Attic/message-audit.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/sql/oracle/message-audit.sql 3 Dec 2002 17:26:34 -0000 1.1
@@ -0,0 +1,51 @@
+--
+-- Auditing of messages
+--
+-- @author Peter Marklund
+--
+-- @creation-date 15 November 2002
+
+create table lang_messages_audit (
+ message_key varchar2(200)
+ constraint lang_messages_audit_key_nn
+ not null,
+ package_key varchar2(100)
+ constraint lang_messages_audit_p_key_nn
+ not null,
+ locale varchar2(30)
+ constraint lang_messages_audit_l_fk
+ references ad_locales(locale)
+ constraint lang_messages_audit_l_nn
+ not null,
+ message clob,
+ overwrite_date date default sysdate not null,
+ overwrite_user integer
+ constraint lang_messages_audit_ou_fk
+ references users (user_id),
+ constraint lang_messages_audit_fk
+ foreign key (message_key, package_key)
+ references lang_message_keys(message_key, package_key)
+ on delete cascade
+);
+
+create table lang_messages_created (
+ message_key varchar2(200)
+ constraint lang_messages_create_key_nn
+ not null,
+ package_key varchar2(100)
+ constraint lang_messages_create_p_key_nn
+ not null,
+ locale varchar2(30)
+ constraint lang_messages_create_l_fk
+ references ad_locales(locale)
+ constraint lang_messages_create_l_nn
+ not null,
+ creation_date date default sysdate not null,
+ creation_user integer
+ constraint lang_messages_create_ou_fk
+ references users (user_id),
+ constraint lang_messages_create_fk
+ foreign key (message_key, package_key)
+ references lang_message_keys(message_key, package_key)
+ on delete cascade
+);
Index: openacs-4/packages/acs-lang/sql/oracle/message-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/oracle/message-catalog-drop.sql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/sql/oracle/message-catalog-drop.sql 7 Oct 2002 14:32:42 -0000 1.3
+++ openacs-4/packages/acs-lang/sql/oracle/message-catalog-drop.sql 3 Dec 2002 17:26:34 -0000 1.4
@@ -17,6 +17,7 @@
drop table lang_translation_registry;
drop table lang_translate_columns;
drop table lang_messages;
+drop table lang_user_timezone;
-- This might fail if the data model includes other multilingual tables
-- that reference ad_locales. Really need to cascade here to ensure
Index: openacs-4/packages/acs-lang/sql/oracle/message-catalog.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/oracle/message-catalog.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-lang/sql/oracle/message-catalog.sql 21 Oct 2002 11:39:08 -0000 1.4
+++ openacs-4/packages/acs-lang/sql/oracle/message-catalog.sql 3 Dec 2002 17:26:34 -0000 1.5
@@ -8,6 +8,14 @@
-- @creation-date 2000-09-10
-- @cvs-id $Id$
--
+
+create table lang_user_timezone (
+ user_id integer
+ constraint lang_user_timezone_user_id_fk
+ references users (user_id) on delete cascade,
+ timezone varchar2(100)
+);
+
create table lang_message_keys (
message_key varchar2(200)
constraint lang_message_keys_m_key_nn
@@ -48,6 +56,29 @@
into an nsv_array.
';
+create table lang_messages_audit (
+ message_key varchar2(200)
+ constraint lang_messages_audit_key_nn
+ not null,
+ package_key varchar2(100)
+ constraint lang_messages_audit_p_key_nn
+ not null,
+ locale varchar2(30)
+ constraint lang_messages_audit_l_fk
+ references ad_locales(locale)
+ constraint lang_messages_audit_l_nn
+ not null,
+ message clob,
+ overwrite_date date default sysdate not null,
+ overwrite_user integer
+ constraint lang_messages_audit_ou_fk
+ references users (user_id),
+ constraint lang_messages_audit_fk
+ foreign key (message_key, package_key)
+ references lang_message_keys(message_key, package_key)
+ on delete cascade
+);
+
-- ****************************************************************************
-- * The lang_translate_columns table holds the columns that require translation.
-- * It is needed to generate the user interface for translating the web site.
Index: openacs-4/packages/acs-lang/sql/postgresql/ad-locales.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/postgresql/ad-locales.sql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/acs-lang/sql/postgresql/ad-locales.sql 15 Nov 2002 15:08:59 -0000 1.6
+++ openacs-4/packages/acs-lang/sql/postgresql/ad-locales.sql 3 Dec 2002 17:26:44 -0000 1.7
@@ -55,8 +55,6 @@
create table ad_locale_user_prefs (
user_id integer
- constraint ad_locale_user_prefs_pk
- primary key
constraint ad_locale_user_prefs_users_fk
references users (user_id) on delete cascade,
package_id integer
Index: openacs-4/packages/acs-lang/sql/postgresql/message-catalog-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/postgresql/message-catalog-drop.sql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-lang/sql/postgresql/message-catalog-drop.sql 10 Jul 2002 11:57:19 -0000 1.2
+++ openacs-4/packages/acs-lang/sql/postgresql/message-catalog-drop.sql 3 Dec 2002 17:26:44 -0000 1.3
@@ -17,6 +17,7 @@
drop table lang_translation_registry;
drop table lang_translate_columns;
drop table lang_messages;
+drop table lang_user_timezone;
-- This might fail if the data model includes other multilingual tables
-- that reference ad_locales. Really need to cascade here to ensure
Index: openacs-4/packages/acs-lang/sql/postgresql/message-catalog.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/sql/postgresql/message-catalog.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-lang/sql/postgresql/message-catalog.sql 21 Oct 2002 11:39:10 -0000 1.4
+++ openacs-4/packages/acs-lang/sql/postgresql/message-catalog.sql 3 Dec 2002 17:26:44 -0000 1.5
@@ -9,6 +9,13 @@
begin;
+create table lang_user_timezone (
+ user_id integer
+ constraint lang_user_timezone_user_id_fk
+ references users (user_id) on delete cascade,
+ timezone varchar(30)
+);
+
create table lang_message_keys (
message_key varchar(200)
constraint lang_message_keys_message_key_nn
@@ -43,6 +50,30 @@
primary key (message_key, package_key, locale)
);
+create table lang_messages_audit (
+ message_key varchar(200)
+ constraint lang_messages_audit_key_nn
+ not null,
+ package_key varchar(100)
+ constraint lang_messages_audit_p_key_nn
+ not null,
+ locale varchar(30)
+ constraint lang_messages_audit_l_fk
+ references ad_locales(locale)
+ constraint lang_messages_audit_l_nn
+ not null,
+ message text,
+ overwrite_date date default sysdate not null,
+ overwrite_user integer
+ constraint lang_messages_audit_ou_fk
+ references users (user_id),
+ constraint lang_messages_audit_fk
+ foreign key (message_key, package_key)
+ references lang_message_keys(message_key, package_key)
+ on delete cascade
+);
+
+
-- ****************************************************************************
-- * The lang_translate_columns table holds the columns that require translation.
-- * It is needed to generate the user interface for translating the web site.
Index: openacs-4/packages/acs-lang/tcl/acs-lang-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/acs-lang-init.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/tcl/acs-lang-init.tcl 12 Nov 2002 15:33:15 -0000 1.3
+++ openacs-4/packages/acs-lang/tcl/acs-lang-init.tcl 3 Dec 2002 17:26:54 -0000 1.4
@@ -9,6 +9,5 @@
# Load message catalog files from packages that don't have messages in the database already
# This is done in a scheduled proc so that it won't take up time at server startup.
# Instead, it can be done by a thread after the server has started multithreading.
-ad_schedule_proc -once t 5 lang::catalog::import_from_all_files
-
-lang::message::cache
+# The proc also reloads the message cache
+ad_schedule_proc -once t 5 lang::catalog::import_from_all_files_and_cache
Index: openacs-4/packages/acs-lang/tcl/lang-audit-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-audit-procs-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/tcl/lang-audit-procs-oracle.xql 3 Dec 2002 17:26:54 -0000 1.1
@@ -0,0 +1,16 @@
+
+
+ oracle8.1.6
+
+
+
+ insert into lang_messages_audit (package_key, message_key, locale, message, overwrite_user)
+ values (:package_key, :message_key, :locale, empty_clob(), :overwrite_user)
+ returning message into :1
+
+
+
+
+
+
+
Index: openacs-4/packages/acs-lang/tcl/lang-audit-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-audit-procs-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/tcl/lang-audit-procs-postgresql.xql 3 Dec 2002 17:26:54 -0000 1.1
@@ -0,0 +1,16 @@
+
+
+ postgresql7.2
+
+
+
+ insert into lang_messages_audit (package_key, message_key, locale, message, overwrite_user)
+ values (:package_key, :message_key, :locale, :message, :overwrite_user)
+ returning message into :1
+
+
+
+
+
+
+
Index: openacs-4/packages/acs-lang/tcl/lang-audit-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-audit-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/tcl/lang-audit-procs.tcl 3 Dec 2002 17:26:54 -0000 1.1
@@ -0,0 +1,26 @@
+#/packages/acs-lang/tcl/lang-message-procs.tcl
+ad_library {
+
+ Auditing of lang_messages
+
+ @creation-date 15 October 2000
+ @author Peter Marklund (peter@collaboraid.biz)
+ @cvs-id $Id: lang-audit-procs.tcl,v 1.1 2002/12/03 17:26:54 peterm Exp $
+}
+
+namespace eval lang::audit {
+
+ ad_proc -public changed_message {
+ old_message
+ package_key
+ message_key
+ locale
+ } {
+ Save a message that is overwritten.
+ @author Peter Marklund
+ } {
+ # Save the old message in the audit table
+ set overwrite_user [ad_conn user_id]
+ db_dml lang_message_audit {} -clobs [list $old_message]
+ }
+}
Index: openacs-4/packages/acs-lang/tcl/lang-catalog-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-catalog-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/tcl/lang-catalog-procs.tcl 7 Nov 2002 12:13:51 -0000 1.3
+++ openacs-4/packages/acs-lang/tcl/lang-catalog-procs.tcl 3 Dec 2002 17:26:54 -0000 1.4
@@ -215,7 +215,8 @@
} {
# Put the messages in an array so it's easier to access them
array set messages_array $messages_list
- set message_key_list [lsort [array names messages_array]]
+ # Sort the keys so that it's easier to manually read and edit the catalog files
+ set message_key_list [lsort -dictionary [array names messages_array]]
# Extract package_key, locale, and charset from the file path
if { ![regexp {(?i)([^/]+)\.([a-z]{2}_[a-z]{2})\.(.*)\.xml$} $file_path match package_key locale charset] } {
@@ -355,9 +356,10 @@
return $files
}
- ad_proc -public import_from_all_files {} {
+ ad_proc -public import_from_all_files_and_cache {} {
Loops over all installed and enabled packages that don't already have messages in the database
- and imports messages from the catalog files of each such package.
+ and imports messages from the catalog files of each such package. When this process is done
+ the message cache is reloaded.
@author Peter Marklund (peter@collaboraid.biz)
} {
@@ -366,6 +368,8 @@
lang::catalog::import_from_files $package_key
}
}
+
+ lang::message::cache
}
ad_proc -private translate {} {
Index: openacs-4/packages/acs-lang/tcl/lang-catalog-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-catalog-procs.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-lang/tcl/lang-catalog-procs.xql 21 Oct 2002 11:39:12 -0000 1.2
+++ openacs-4/packages/acs-lang/tcl/lang-catalog-procs.xql 3 Dec 2002 17:26:54 -0000 1.3
@@ -1,7 +1,7 @@
-
+
select package_key
from apm_package_types
Index: openacs-4/packages/acs-lang/tcl/lang-message-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs-oracle.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/tcl/lang-message-procs-oracle.xql 12 Nov 2002 22:34:19 -0000 1.3
+++ openacs-4/packages/acs-lang/tcl/lang-message-procs-oracle.xql 3 Dec 2002 17:26:54 -0000 1.4
@@ -21,16 +21,6 @@
-
-
- select message
- from lang_messages
- where message_key = :message_key
- and package_key = :package_key
- and rownum = 1
-
-
-
Index: openacs-4/packages/acs-lang/tcl/lang-message-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs-postgresql.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-lang/tcl/lang-message-procs-postgresql.xql 12 Nov 2002 22:34:19 -0000 1.4
+++ openacs-4/packages/acs-lang/tcl/lang-message-procs-postgresql.xql 3 Dec 2002 17:26:54 -0000 1.5
@@ -19,14 +19,4 @@
-
-
- select message
- from lang_messages
- where message_key = :message_key
- and package_key = :package_key
- limit 1
-
-
-
Index: openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl,v
diff -u -r1.13 -r1.14
--- openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 12 Nov 2002 22:34:19 -0000 1.13
+++ openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 3 Dec 2002 17:26:54 -0000 1.14
@@ -63,35 +63,16 @@
set locale [util_memoize [list ad_locale_locale_from_lang $locale]]
}
- if { $key_exists_p } {
- # The message key exists so register has been invoked before with
- # this key. Check that embedded variables are unchanged in the new message.
-
- # Attempt to get the en_US message from the cache, or get a message
- # in any locale from the database for variable comparison
- if { [nsv_exists lang_message_en_us $key] } {
- set existing_en_us_message [nsv_get lang_message_en_US $key]
- } else {
- set existing_en_us_message [db_string select_an_existing_message {}]
- }
-
- set missing_vars_list [get_missing_embedded_vars $existing_en_us_message $message]
- if { [llength $missing_vars_list] != 0 } {
- error "The following variables are in the en_US message for key $message_key but not in the new message \"$message\" in locale $locale : $missing_vars_list"
- }
- }
-
# Check the cache
if { [nsv_exists lang_message_$locale $key] } {
- # Update existing message
- set old_message [nsv_get lang_message_$locale $key]
+ # Update existing message if the message has changed
+ set old_message [nsv_get lang_message_$locale $key]
if { ![string equal $message $old_message] } {
- # changed message ... update.
+ lang::audit::changed_message $old_message $package_key $message_key $locale
- # Trying to avoid hitting Oracle bug#2011927
-
+ # Trying to avoid hitting Oracle bug#2011927
if { [empty_string_p [string trim $message]] } {
db_dml lang_message_null_update {}
} else {
@@ -104,7 +85,7 @@
ns_log Debug "lang::message::register - Inserting into database message: $locale $key"
db_transaction {
# As above, avoiding the bug#2011927 from Oracle.
-
+
if { [empty_string_p [string trim $message]] } {
db_dml lang_message_insert_null_msg {}
} else {
Index: openacs-4/packages/acs-lang/tcl/lang-message-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-lang/tcl/lang-message-procs.xql 21 Oct 2002 11:39:12 -0000 1.2
+++ openacs-4/packages/acs-lang/tcl/lang-message-procs.xql 3 Dec 2002 17:26:54 -0000 1.3
@@ -10,6 +10,15 @@
+
+
+ select count(*)
+ from lang_messages
+ where package_key = :package_key
+ and message_key = :message_key
+
+
+
insert into lang_message_keys
Index: openacs-4/packages/acs-lang/tcl/locale-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/Attic/locale-procs-oracle.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-lang/tcl/locale-procs-oracle.xql 7 Oct 2002 14:32:46 -0000 1.2
+++ openacs-4/packages/acs-lang/tcl/locale-procs-oracle.xql 3 Dec 2002 17:26:54 -0000 1.3
@@ -6,7 +6,7 @@
- select ( (sysdate - timezone.local_to_utc (:system_timezone, sysdate)) * 24 ) from dual
+ select ( (sysdate - timezone.local_to_utc (timezone.get_id(:system_timezone), sysdate)) * 24 ) from dual
Index: openacs-4/packages/acs-lang/tcl/locale-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/acs-lang/tcl/locale-procs.tcl 12 Nov 2002 15:33:15 -0000 1.7
+++ openacs-4/packages/acs-lang/tcl/locale-procs.tcl 3 Dec 2002 17:26:54 -0000 1.8
@@ -15,6 +15,20 @@
namespace eval lang::system {
+ ad_proc -public site_wide_locale {
+ } {
+ Get the site wide system locale setting.
+ } {
+ set package_id [apm_package_id_from_key "acs-lang"]
+ return [parameter::get -package_id $package_id -parameter SiteWideLocale]
+ }
+
+ ad_proc -public package_level_locale {
+ package_id
+ } {
+ return {}
+ }
+
ad_proc -public locale {
{-package_id ""}
{-site_wide:boolean}
@@ -25,18 +39,17 @@
@param site_wide Set this if you want to get the site-wide locale setting.
} {
if { $site_wide_p } {
- set package_id [apm_package_id_from_key "acs-lang"]
- return [parameter::get -package_id $package_id -parameter SiteWideLocale]
+ return [site_wide_locale]
}
if { [empty_string_p $package_id] } {
set package_id [ad_conn package_id]
}
- # Pssst! We don't actually use this package thing,
- # but we'll probably do so later.
- set locale {}
+ # get locale from lang_package_locale
+ set locale [package_level_locale $package_id]
+
# If there's no package setting, use the site-wide setting
if { [empty_string_p $locale] } {
set locale [locale -site_wide]
@@ -87,7 +100,7 @@
@return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York)
} {
set package_id [apm_package_id_from_key "acs-lang"]
- return [parameter::get -package_id $package_id -parameter SystemTimezone -default 0]
+ return [parameter::get -package_id $package_id -parameter SystemTimezone -default "America/New_York"]
}
ad_proc -public set_timezone {
@@ -112,6 +125,36 @@
namespace eval lang::user {
+ ad_proc -public package_level_locale {
+ package_id
+ } {
+ Get the user's preferred package level locale for a package
+ given by its package id.
+
+ } {
+ set user_id [ad_conn user_id]
+ if { [string equal $user_id 0] } {
+
+ # if the user is not logged in then use a session
+ # variable - right now this is only for acs-lang - aka the
+ # site wide locale
+
+ if { [string equal $package_id [apm_package_id_from_key "acs-lang"] ] } {
+ return [ad_get_client_property -cache t "acs-lang" "user_locale"]
+ }
+ return ""
+ }
+ set locale [db_string get_user_locale {} -default ""]
+ return $locale
+ }
+
+ ad_proc -public site_wide_locale {
+ } {
+ Get the user's preferred site wide locale.
+ } {
+ return [package_level_locale [apm_package_id_from_key "acs-lang"]]
+ }
+
ad_proc -public locale {
{-package_id ""}
{-site_wide:boolean}
@@ -122,27 +165,20 @@
@param package_id The package for which you want to get the locale preference.
@param site_wide Set this if you want to get the site-wide locale preference.
} {
- set user_id [ad_conn user_id]
- if { $user_id == 0 } {
- # Not logged in, use a session-based client property
- return [ad_get_client_property -cache t "acs-lang" "user_locale"]
- }
-
- # Pssst! We don't actually use this package thing,
- # but we'll probably do so later.
- if { $site_wide_p } {
+ # default value for package_id
- set package_id [apm_package_id_from_key "acs-lang"]
- return [db_string get_user_locale {} -default ""]
-
- } elseif { [empty_string_p $package_id] } {
+ if { [empty_string_p $package_id] } {
set package_id [ad_conn package_id]
}
- set locale [db_string get_user_locale {} -default ""]
- # If there's no package setting, use the site-wide setting
+ # get package level locale
+
+ set locale [package_level_locale $package_id]
+
+ # If there's no package setting, then use the site-wide setting
+
if { [empty_string_p $locale] } {
- set locale [locale -site_wide]
+ set locale [site_wide_locale]
}
return $locale
}
@@ -166,13 +202,11 @@
return
}
- # Pssst! We don't actually use this package thing,
- # but we'll probably do so later.
if { $site_wide_p } {
set package_id [apm_package_id_from_key "acs-lang"]
} elseif { [empty_string_p $package_id] } {
set package_id [ad_conn package_id]
- }
+ }
set user_locale_exists_p [db_string user_locale_exists_p {}]
if { $user_locale_exists_p } {
@@ -202,18 +236,15 @@
}
ad_proc -public timezone {} {
- Get the user's timezone. Defaults to system timezone if the user has no setting.
+ Get the user's timezone. Returns the empty string if the user
+ has no timezone set.
@return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York)
} {
+ # FIXME:
# We probably don't want to keep this in client properties, since these are
# no longer permanent. We'll move this into a DB table at some point.
- set timezone [ad_get_client_property -cache t "acs-lang" "timezone"]
- if { [empty_string_p $timezone] } {
- # No user timezone, return the system timezone
- set timezone [parameter::get -parameter DefaultTimezone -package_id [apm_package_id_from_key acs-lang] -default "PST"]
- }
- return $timezone
+ return [ad_get_client_property -cache t "acs-lang" "timezone"]
}
ad_proc -public set_timezone {
@@ -223,6 +254,10 @@
@param timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York)
} {
+ # FIXME: (lars)
+ # This shouldn't be in client properties, since they're session-based
+ # I'm doing this for now, because I don't know whether we'll use a separate table,
+ # like with the locale setting, or the user-profile package.
ad_set_client_property -persistent t "acs-lang" timezone $timezone
}
@@ -241,20 +276,49 @@
@param package_id The package for which you want to get the locale.
@param site_wide Set this if you want to get the site-wide locale.
} {
- set locale {}
- catch {
- set locale [lang::user::locale -package_id $package_id -site_wide=$site_wide_p]
- }
- if { [empty_string_p $locale] } {
- catch {
- set locale [lang::system::locale -package_id $package_id -site_wide=$site_wide_p]
+ if { $site_wide_p } {
+ set locale [lang::user::site_wide_locale]
+ if { [empty_string_p $locale] } {
+ set locale [lang::system::site_wide_locale]
}
+ return $locale
}
-
- # Check browser Accept-Language header
- # Hm. Site-wide will always be set. Hm.
- # Check Yon's ACS Java g15n doc
-
+
+ # default value for package_id
+
+ if { [empty_string_p $package_id] } {
+ set package_id [ad_conn package_id]
+ }
+
+ # use user's package level locale
+
+ set locale [lang::user::package_level_locale $package_id]
+
+ # if that does not exist use system's package level locale
+
+ if { [empty_string_p $locale] } {
+ set locale [lang::system::package_level_locale $package_id]
+ }
+
+ # if that does not exist use user's site wide locale
+
+ if { [empty_string_p $locale] } {
+ set locale [lang::user::site_wide_locale]
+ }
+
+ # if that does not exist use system's site wide locale
+
+ if { [empty_string_p $locale] } {
+ set locale [lang::system::site_wide_locale]
+ }
+
+ # if that does not exist then we are back to just another language
+ # let's pick uhmm... en_US
+
+ if { [empty_string_p $locale] } {
+ set locale en_US
+ }
+
return $locale
}
@@ -280,6 +344,20 @@
} {
return [lang::util::charset_for_locale [lang::conn::locale]]
}
+
+ ad_proc -public timezone {} {
+ Get this connection's timezone. This is the user timezone, if
+ set, otherwise the system timezone.
+
+ @return a timezone name from acs-reference package (e.g., Asia/Tokyo, America/New_York)
+ } {
+ set timezone [lang::user::timezone]
+ if { [empty_string_p $timezone] } {
+ # No user timezone, return the system timezone
+ set timezone [lang::system::timezone]
+ }
+ return $timezone
+ }
}
@@ -291,7 +369,7 @@
ad_proc -deprecated -warn ad_locale {
context
- item
+ {item "locale"}
} {
Returns the value of a locale item in a particular context. For example, to
get the language, locale, and timezone preference for the current user:
@@ -332,7 +410,20 @@
} {
switch $context {
request {
- return [lang::conn::locale -site_wide]
+ switch $item {
+ locale {
+ return [lang::conn::locale -site_wide]
+ }
+ language {
+ return [lang::conn::language -site_wide]
+ }
+ timezone {
+ return [lang::conn::timezone]
+ }
+ default {
+ error "unsupported option to ad_locale: $item"
+ }
+ }
}
user {
switch $item {
Index: openacs-4/packages/acs-lang/tcl/locale-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/tcl/locale-procs.xql 28 Oct 2002 12:32:45 -0000 1.3
+++ openacs-4/packages/acs-lang/tcl/locale-procs.xql 3 Dec 2002 17:26:54 -0000 1.4
@@ -1,11 +1,12 @@
-
+
- select locale
- from ad_locale_user_prefs
+ select locale
+ from ad_locale_user_prefs
where user_id = :user_id
+ and package_id = :package_id
@@ -15,27 +16,28 @@
select count(*)
from ad_locale_user_prefs
where user_id = :user_id
+ and package_id = :package_id
- update ad_locale_user_prefs set locale = :locale where user_id = :user_id
+ update ad_locale_user_prefs set locale = :locale where user_id = :user_id and package_id = :package_id
- insert into ad_locale_user_prefs (user_id, locale) values (:user_id, :locale)
+ insert into ad_locale_user_prefs (user_id, package_id, locale) values (:user_id, :package_id, :locale)
- delete from ad_locale_user_prefs where user_id = :user_id
+ delete from ad_locale_user_prefs where user_id = :user_id and package_id = :package_id
Index: openacs-4/packages/acs-lang/tcl/localization-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/localization-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/acs-lang/tcl/localization-procs.tcl 18 Nov 2002 17:58:35 -0000 1.5
+++ openacs-4/packages/acs-lang/tcl/localization-procs.tcl 3 Dec 2002 17:26:54 -0000 1.6
@@ -540,16 +540,20 @@
ad_proc -public lc_time_utc_to_local {
time_value
- tz
+ {tz ""}
} {
Converts a Universal Time to local time for the specified timezone.
@param time_value UTC time in the ISO datetime format.
@param tz Timezone that must exist in tz_data table.
@return Local time
} {
+ if { [empty_string_p $tz] } {
+ set tz [lang::conn::timezone]
+ }
set local_time $time_value
+
if {[catch {
set local_time [db_exec_plsql utc_to_local {}]
} errmsg]
@@ -567,14 +571,18 @@
ad_proc -public lc_time_local_to_utc {
time_value
- tz
+ {tz ""}
} {
Converts a local time to a UTC time for the specified timezone.
- @param time_value Local time in the ISO datetime format.
+ @param time_value Local time in the ISO datetime format, YYYY-MM-DD HH24:MI:SS
@param tz Timezone that must exist in tz_data table.
@return UTC time.
} {
+ if { [empty_string_p $tz] } {
+ set tz [lang::conn::timezone]
+ }
+
set utc_time $time_value
if {[catch {
set utc_time [db_exec_plsql local_to_utc {}]
Index: openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/tcl/test/acs-lang-test-procs.tcl 3 Dec 2002 17:27:04 -0000 1.1
@@ -0,0 +1,220 @@
+ad_library {
+ Test TCL procedures in the acs-lang package with acs-automated-testing.
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 18 October 2002
+}
+
+namespace eval lang::test {
+
+ ad_proc get_dir {} {
+ The test directory of the acs-lang package (where this file resides).
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 28 October 2002
+ } {
+ return "[acs_package_root_dir acs-lang]/tcl/test"
+ }
+}
+
+aa_register_case util__replace_temporary_tags_with_lookups {
+ Primarily tests lang::util::replace_temporary_tags_with_lookups,
+ Also tests the procs lang::catalog::export_messages_to_file, lang::catalog::parse,
+ lang::catalog::read_file, and lang::util::get_temporary_tags_indices.
+
+ A test tcl file and catalog file are created. The temporary tags in the
+ tcl file are replaced with message lookups and keys and messages are appended
+ to the catalog file.
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 18 October 2002
+} {
+ # The files involved in the test
+ set test_dir [lang::test::get_dir]
+ set catalog_file "${test_dir}/acs-lang.en_US.ISO-8859-1.xml"
+ set backup_file_suffix ".orig"
+ set catalog_backup_file "${catalog_file}${backup_file_suffix}"
+ regexp {^.*(packages/.*)$} $test_dir match test_dir_rel
+ set tcl_file "${test_dir_rel}/test-message-tags.tcl"
+ set tcl_backup_file "${tcl_file}${backup_file_suffix}"
+
+ # The test messages to use for the catalog file
+ array set messages_array [list key_1 text_1 key_2 text_2 key_3 text_3]
+
+ # Write the test tcl file
+ set tcl_file_id [open "[acs_root_dir]/$tcl_file" w]
+ set new_key_1 "_"
+ set new_text_1 "Auto Key"
+ set new_key_2 "key_1"
+ set new_text_2 "text_1_different"
+ set new_key_3 "key_1"
+ set new_text_3 "$messages_array(key_1)"
+ puts $tcl_file_id "# The following key should be auto-generated and inserted
+ # <#${new_key_1} ${new_text_1}#>
+ #
+ # The following key should be made unique and inserted
+ # <#${new_key_2} ${new_text_2}#>
+ #
+ # The following key should not be inserted in the message catalog
+ # <#${new_key_3} ${new_text_3}#>"
+ close $tcl_file_id
+
+ # Write the catalog file
+ lang::catalog::export_messages_to_file $catalog_file [array get messages_array]
+
+ # Replace message tags in the tcl file and insert into catalog file
+ lang::util::replace_temporary_tags_with_lookups -catalog_file_path $catalog_file $tcl_file
+
+ # Read the contents of the catalog file
+ array set catalog_array [lang::catalog::parse [lang::catalog::read_file $catalog_file]]
+ array set updated_messages_array [lindex [array get catalog_array messages] 1]
+
+ # Assert that the old messages are unchanged
+ foreach old_message_key [array names messages_array] {
+ aa_true "old key $old_message_key should be unchanged" [string equal $messages_array($old_message_key) \
+ $updated_messages_array($old_message_key)]
+ }
+
+ # Check that the first new key was autogenerated
+ ns_log Notice "auto key compare \"$updated_messages_array(Auto_Key)\" - \"$new_text_1\""
+ aa_true "check autogenerated key" [string equal $updated_messages_array(Auto_Key) $new_text_1]
+
+ # Check that the second new key was made unique and inserted
+ aa_true "check key made unique" [string equal $updated_messages_array(${new_key_2}_1) $new_text_2]
+
+ # Check that the third key was not inserted
+ aa_true "third key not inserted" [string equal [lindex [array get updated_messages_array $new_key_3] 1] \
+ $messages_array($new_key_3)]
+
+ # Check that there are no tags left in the tcl file
+ set tcl_file_id [open "[acs_root_dir]/$tcl_file" r]
+ set updated_tcl_contents [read $tcl_file_id]
+ close $tcl_file_id
+ aa_true "tags in tcl file replaced" [expr [llength [lang::util::get_temporary_tags_indices $updated_tcl_contents]] == 0]
+
+ # Delete the catalog files
+ file delete $catalog_backup_file
+ file delete $catalog_file
+
+ # Delete the tcl files
+ file delete "[acs_root_dir]/$tcl_file"
+ file delete "[acs_root_dir]/$tcl_backup_file"
+}
+
+aa_register_case util__get_hash_indices {
+ Tests the lang::util::get_hash_indices proc
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 21 October 2002
+} {
+ set multilingual_string "#package1.key1# abc\# #package2.key2#"
+ set indices_list [lang::util::get_hash_indices $multilingual_string]
+ set expected_indices_list [list [list 0 14] [list 21 35]]
+
+ aa_true "there should be two hash entries" [expr [llength $indices_list] == 2]
+
+ set counter 0
+ foreach index_item $indices_list {
+ set expected_index_item [lindex $expected_indices_list $counter]
+
+ aa_true "checking start and end indices of item $counter" \
+ [expr [string equal [lindex $index_item 0] [lindex $expected_index_item 0]] && \
+ [string equal [lindex $index_item 1] [lindex $expected_index_item 1]]]
+
+ set counter [expr $counter + 1]
+ }
+}
+
+aa_register_case util__convert_adp_variables_to_percentage_signs {
+ Tests the lang::util::convert_adp_variables_to_percentage_signs proc.
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 25 October 2002
+} {
+ set adp_chunk "@array.variable_name@ @variable_name2@ peter@collaboraid.biz"
+
+ set adp_chunk_converted [lang::util::convert_adp_variables_to_percentage_signs $adp_chunk]
+ set adp_chunk_expected "%array.variable_name% %variable_name2% peter@collaboraid.biz"
+
+ aa_true "adp vars should be subsituted with percentage sings" [string equal $adp_chunk_converted \
+ $adp_chunk_expected]
+
+ # Test that a string can start with adp vars
+ set adp_chunk "@first_names@ @last_name@ peter@collaboraid.biz"
+ set adp_chunk_converted [lang::util::convert_adp_variables_to_percentage_signs $adp_chunk]
+ set adp_chunk_expected "%first_names% %last_name% peter@collaboraid.biz"
+ aa_true "adp vars should be subsituted with percentage sings" [string equal $adp_chunk_converted \
+ $adp_chunk_expected]
+}
+
+aa_register_case util__replace_adp_text_with_message_tags {
+ Test the lang::util::replace_adp_text_with_message_tags proc.
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 28 October 2002
+} {
+ # File paths used
+ set adp_file_path "[lang::test::get_dir]/adp_tmp_file.adp"
+
+ # Write the adp test file
+ set adp_file_id [open $adp_file_path w]
+ puts $adp_file_id "
+@first_names@ @last_name@ peter@collaboraid.biz
+@context_bar@
+Test text"
+ close $adp_file_id
+
+ # Do the substitutions
+ lang::util::replace_adp_text_with_message_tags $adp_file_path "write"
+
+ # Read the changed test file
+ set adp_file_id [open $adp_file_path r]
+ set adp_contents [read $adp_file_id]
+ close $adp_file_id
+
+ set expected_adp_pattern {
+<#[a-zA-Z_]+ %first_names% %last_name% peter@collaboraid.biz#>
+@context_bar@
+<#[a-zA-Z_]+ Test text\s*}
+
+ ns_log Notice "adp_contents $adp_contents"
+
+ # Assert proper replacements have been done
+ aa_true "replacing adp text with tags" \
+ [regexp $expected_adp_pattern $adp_contents match]
+
+ # Remove the adp test file
+ file delete $adp_file_path
+}
+
+aa_register_case message__format {
+ Tests the lang::message::format proc
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 21 October 2002
+} {
+
+ set localized_message "The %frog% jumped across the %fence%. About 50% of the time, he stumbled, or maybe it was %%20 %times%."
+ set value_list {frog frog fence fence}
+
+ set subst_message [lang::message::format $localized_message $value_list]
+ set expected_message "The frog jumped across the fence. About 50% of the time, he stumbled, or maybe it was %20 %times%."
+
+ aa_true "the frog should jump across the fence" [string equal $subst_message \
+ $expected_message]
+}
+
+aa_register_case message__get_missing_embedded_vars {
+ Tests the lang::message::get_missing_embedded_vars proc
+
+ @author Peter Marklund (peter@collaboraid.biz)
+ @creation-date 12 November 2002
+} {
+ set en_us_message "this is a message with some %vars% and some more %variables%"
+ set new_message "this message contains no vars"
+
+ set missing_vars_list [lang::message::get_missing_embedded_vars $en_us_message $new_message]
+
+ aa_true "check the missing vars" [expr [string equal [lindex $missing_vars_list 0] "vars"] && \
+ [string equal [lindex $missing_vars_list 1] "variables"]]
+}
Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/acs-lang/tcl/test/acs-lang-test.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/acs-lang/www/change-locale-include.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/change-locale-include.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-lang/www/change-locale-include.tcl 21 Nov 2002 15:12:06 -0000 1.4
+++ openacs-4/packages/acs-lang/www/change-locale-include.tcl 3 Dec 2002 17:27:14 -0000 1.5
@@ -41,10 +41,10 @@
if { ($package_id != "") && ([ad_conn user_id] != 0) } {
element create locale package_level_explain -datatype text -widget inform -label " " \
- -value "Your locale setting for this specific [apm_package_key_from_id $package_id] package. This will override the site-wide setting if it is set."
+ -value "Your locale setting for [apm_instance_name_from_id $package_id]. If set, this will override the site-wide setting in this particular application."
element create locale package_level_locale -datatype text -widget select -optional \
- -label "Locale for this [apm_package_key_from_id $package_id]" \
+ -label "Locale for [apm_instance_name_from_id $package_id]" \
-options $list_of_locales
}
Index: openacs-4/packages/acs-lang/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/index.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/www/index.adp 15 Nov 2002 09:22:43 -0000 1.3
+++ openacs-4/packages/acs-lang/www/index.adp 3 Dec 2002 17:27:14 -0000 1.4
@@ -3,13 +3,7 @@
@context_bar@
-
+ Administration
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-lang/www/set-system-timezone-oracle.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/acs-lang/www/set-system-timezone-postgresql.xql'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/acs-lang/www/set-system-timezone.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/acs-lang/www/admin/audit-include.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/audit-include.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/audit-include.adp 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,20 @@
+
+
+Current translation by @current_message_author@ at @current_message_date@
+
+
+
+
+
+Translation History:
+
+
+- "@audit_trail.message@" by @audit_trail.creation_user@ at @audit_trail.creation_date@
+
+
+
+
+
+
+Original translation: "@original_message@"
+
Index: openacs-4/packages/acs-lang/www/admin/audit-include.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/audit-include.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/audit-include.tcl 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,32 @@
+set trail_counter 0
+multirow create audit_trail message creation_user creation_date
+db_foreach audit_trail_select {
+ select a.message,
+ p.first_names || ' ' || p.last_name as overwrite_user,
+ to_char(a.overwrite_date, 'YYYY-MM-DD HH24:MI:SS') as overwrite_date
+ from lang_messages_audit a,
+ persons p
+ where locale = :current_locale
+ and message_key = :message_key
+ and package_key = :package_key
+ and a.overwrite_user = p.person_id
+ order by overwrite_date desc
+} {
+
+ if { [string equal $trail_counter 0] } {
+ set current_message_author $overwrite_user
+ set current_message_date $overwrite_date
+
+ } else {
+ multirow append audit_trail $previous_message $overwrite_user $overwrite_date
+ }
+
+ set previous_message $message
+ set previous_overwrite_user $overwrite_user
+ set previous_overwrite_date $overwrite_date
+ incr trail_counter
+}
+
+if { $trail_counter > 0 } {
+ set original_message $previous_message
+}
Index: openacs-4/packages/acs-lang/www/admin/batch-editor.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/batch-editor.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-lang/www/admin/batch-editor.adp 12 Nov 2002 15:34:23 -0000 1.1
+++ openacs-4/packages/acs-lang/www/admin/batch-editor.adp 3 Dec 2002 17:27:23 -0000 1.2
@@ -25,3 +25,5 @@
+
+
Index: openacs-4/packages/acs-lang/www/admin/batch-editor.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/batch-editor.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-lang/www/admin/batch-editor.tcl 12 Nov 2002 15:34:23 -0000 1.1
+++ openacs-4/packages/acs-lang/www/admin/batch-editor.tcl 3 Dec 2002 17:27:23 -0000 1.2
@@ -38,7 +38,7 @@
set count 0
set keys [list]
-
+set displayed_keys [list]
db_foreach get_messages {
select lm1.message_key as message_key,
lm1.message as default_message
@@ -58,6 +58,7 @@
message_key =:message_key and
locale =:current_locale
}
+ lappend displayed_keys $message_key
element create batch_editor "message_key_$count" -widget hidden -datatype text
element create batch_editor "message_key_info_$count" -widget inform -datatype text -label "key"
element create batch_editor "en_us_message_$count" -widget inform -datatype text -label "American"
Index: openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp 12 Nov 2002 15:34:23 -0000 1.5
+++ openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp 3 Dec 2002 17:27:23 -0000 1.6
@@ -21,3 +21,7 @@
+
+
+
+
Index: openacs-4/packages/acs-lang/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/index.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/acs-lang/www/admin/index.adp 15 Nov 2002 10:42:25 -0000 1.6
+++ openacs-4/packages/acs-lang/www/admin/index.adp 3 Dec 2002 17:27:23 -0000 1.7
@@ -29,6 +29,11 @@
+ Set system timezone
+
+
+
+
Toggle translator mode (Currently
ON
off)
Index: openacs-4/packages/acs-lang/www/admin/load-catalog-files.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/load-catalog-files.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/acs-lang/www/admin/load-catalog-files.tcl 23 Oct 2002 11:47:37 -0000 1.3
+++ openacs-4/packages/acs-lang/www/admin/load-catalog-files.tcl 3 Dec 2002 17:27:23 -0000 1.4
@@ -6,6 +6,6 @@
@cvs-id $Id$
}
-lang::catalog::import_from_all_files
+lang::catalog::import_from_all_files_and_cache
ad_returnredirect "index"
Index: openacs-4/packages/acs-lang/www/admin/lookups-include.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/lookups-include.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/lookups-include.adp 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,4 @@
+Message key usage:
+
+@message_key_context@
+
Index: openacs-4/packages/acs-lang/www/admin/lookups-include.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/lookups-include.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/lookups-include.tcl 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,13 @@
+# Include takes arguments full_key and message_key_list
+
+set full_key_pattern "${package_key}.([join $message_key_list "|"])"
+
+set message_key_context ""
+if { [catch {set message_key_context [exec find [acs_root_dir] -type f -regex ".*\\.\\(info\\|adp\\|sql\\|tcl\\)" | xargs egrep "${full_key_pattern}"]} error] } {
+ global errorInfo
+ regexp "^(.*)child process exited abnormally" $errorInfo match message_key_context
+ set message_key_context [ad_quotehtml $message_key_context]
+ regsub -all "${full_key_pattern}" $message_key_context {\1} message_key_context
+}
+
+ns_log Notice "PM debug $message_key_context"
Index: openacs-4/packages/acs-lang/www/admin/set-system-timezone-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/set-system-timezone-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/set-system-timezone-oracle.xql 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,18 @@
+
+
+
+ oracle8.1.6
+
+
+
+ select to_char(sysdate, 'YYYY-MM-DD HH24:MI:SS') from dual
+
+
+
+
+
+ select to_char(timezone.local_to_utc(timezone.get_id(:system_timezone), sysdate), 'YYYY-MM-DD HH24:MI:SS') from dual
+
+
+
+
Index: openacs-4/packages/acs-lang/www/admin/set-system-timezone-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/set-system-timezone-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/set-system-timezone-postgresql.xql 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+postgresql7.1
+
+
+
+ select to_char(current_time, 'YYYY-MM-DD HH24:MI:SS')
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-lang/www/admin/set-system-timezone.tcl 3 Dec 2002 17:27:23 -0000 1.1
@@ -0,0 +1,57 @@
+# set-system-timezone.tcl
+ad_page_contract {
+ Set the acs-lang system parameter which says what the local timezone offset is
+} {
+ {timezone ""}
+} -properties {
+ page_title
+ system_timezone
+ sysdate
+ system_utc_offset
+ timezones:multirow
+ utc_ansi
+}
+
+if {![empty_string_p $timezone]} {
+ lang::system::set_timezone $timezone
+}
+
+set page_title "Set System Timezone"
+
+set system_timezone [lang::system::timezone]
+
+set sysdate [db_string sysdate {}]
+
+set sysdate_utc [db_string sysdate_utc {}]
+
+set system_utc_offset [lang::system::timezone_utc_offset]
+
+multirow create timezones label value selected_p
+foreach entry [lc_list_all_timezones] {
+ set tz [lindex $entry 0]
+
+ multirow append timezones $entry $tz [string equal $tz $system_timezone]
+}
+
+# Try to get the correct UTC time from www.timeanddate.com
+if { [catch {
+ set time_and_date_page [util_httpget "http://www.timeanddate.com/worldclock/"]
+
+ regexp {Current UTC \(or GMT\)-time used: ([^<]*)} $time_and_date_page match utc_from_page
+
+ # UTC in format:
+ # Wednesday, November 20, 2002, at 2:49:07 PM
+
+ regexp {^([^,]*), ([^ ]*) ([0-9]*), ([0-9]*), at (.*)$} $utc_from_page match weekday month day year time
+
+ set utc_epoch [clock scan "${month} ${day}, ${year} ${time}"]
+
+ set utc_ansi [clock format $utc_epoch -format "%Y-%m-%d %T"]
+
+} errmsg] } {
+ global errorInfo
+ ns_log Error "Problem getting UTC time from timeanddate.com, they may have changed their design so our regexp stopped working.\n$errorInfo"
+
+ set utc_ansi {Couldn't get time from timeanddate.com, sorry.}
+}
+