Forum OpenACS Development: Notification intervals widget i18n

Collapse
Posted by Esti Alvarez on
Hi! I want to internationalize the notifications intervals widget, ie, the notification::get_intervals procedure. It is just a simple select that retrieves the possible values from the database. The problem is that the intervals text is stored in english in the "name" column of the database. I tried the following redefinition of the SQL query:
    <fullquery name="notification::get_intervals.select_intervals">
        <querytext>
            select '[_ notifications.' || name || ']' as name,
                   notification_intervals.interval_id
            from notification_intervals,
                 notification_types_intervals
            where notification_intervals.interval_id = notification_types_intervals.interval_id
            and type_id = :type_id
            order by n_seconds
        </querytext>
    </fullquery>
but it doesn't work because the "_" procedure is evaluated before the || of the SQL. Is there any way of making something like this work? I thought it would be a good way of internationalizing this kind of content. Is there any other way I don't know? Thanks in advance!
Collapse
Posted by Matthew Geddert on
you can't run tcl code within a select statement, but you can pull it out of the database and have the adp parser automatically translate it. You could do one of two things:

Either set up a select query like this:

<fullquery name="notification::get_intervals.select_intervals">
        <querytext>
            select '#notifications.' || name || '#' as name,
                   notification_intervals.interval_id
            from notification_intervals,
                 notification_types_intervals
            where notification_intervals.interval_id = notification_types_intervals.interval_id
            and type_id = :type_id
            order by n_seconds
        </querytext>
    </fullquery>
Note that some types of display procs do not automatically process these snippets - i've encountered this a few times, so if they don't it would need to be the same thing without the hash (#) sign and then run [_ notifications.name] as a separate process in tcl.

Or, even better, if you don't have the problems mentioned above would be to upgrade notifications and store the values as #notification.name# in the database table, that way they show up everywhere as translated messages. This is how thing such as dotlrn relationship types are stored in the db.

Collapse
Posted by Matthew Geddert on
That should be you can't run tcl code that will run on the results within a select statement - you can run tcl code that is processed before the query goes to the database within a select statement - such as the orderby statement for listbuilder query's etc.