Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

javascript alert/confirm/prompt internationalization

#195

Sitellite currently has no feature for internationalizing the text displayed javascript alert/confirm/prompt boxes.

Ideally, a wrapper is created to catch a variant of intl or intl_get coded in javascript sections.
However, a work around is also possible: (eg.)

source: /inc/app/usradm/boxes/browse/_users.php

<?php

    $intconfirm = intl_get ('Are you sure you wish to delete: ');

?>
<script language="javascript">
    <!--

    function confirmDelete (list, key) {
        return confirm ("<?php echo $intconfirm ?>" + list + '/' + key + '?');
    }

    // -->
</script>

This way, the text is read when refreshing the translations index.

Reported by semias · April 15th, 2011 @ 08:30 AM

State: resolved
Milestone: 5.0.4
Assigned to: semias semias

Activity

  1. semias
    semias

    There is another variant of this "issue".

    For instance: when generating .spt files by defining te spt contents as a string variable, the {intl } tags are ignored by the translation indexer.

    Solving this is done by adding a _translate() function, which explicitly runs through all strings in a php file and adds them to the translation table.

    example:

    source: /saf/lib/GUI/DataGrid.php
    
    var $template = '
    {if obj.addUrl}
        <p><a href="{addUrl}?collection={collection}">{intl Add Item}</a></p>
    {end if}
    ';
    
    function _translate () {
        intl_get ('Add Item');
    }
    

    This way, the {intl } tags are discovered and the text is made translatable.

    April 15th, 2011 @ 09:45 AM

  2. semias
    semias

    Sometimes javascript is called using a "define" function. Here the javascript is encapsulated in quotes, so the PHP code has to be inserted in a different manner.
    Example:

    Source: /inc/app/sitemailer2/conf/properties.php
    
    $intl_confirm = intl_get("Are you sure you want to delete this item?");
    
    define ('CMS_JS_DELETE_CONFIRM', '<script language="javascript" type="text/javascript">
    <!--
    
    function cms_delete_confirm () {
        return confirm ("' . $intl_confirm . '");
    }
    
    // -->
    </script>');
    

    April 22nd, 2011 @ 03:49 AM

  3. semias
    semias
    • State changed from new to open

    Every alert and confirm pop-up window has been internationalized.
    There is one exception located at:

    /inc/app/siteblog/lib/Filters.php:50-52
    

    It is possible to translate the given strings, but for some reason they are not translated in the actual view. (which is located in the control panel > content > blog comments)

    April 22nd, 2011 @ 05:28 AM

  4. semias
    semias
    • State changed from open to resolved

    April 22nd, 2011 @ 08:08 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.