#195 ✓resolved
semias

javascript alert/confirm/prompt internationalization

Reported by semias | April 15th, 2011 @ 08:30 AM | in 5.0.4 (closed)

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.

Comments and changes to this ticket

  • semias

    semias April 15th, 2011 @ 09:45 AM

    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.

  • semias

    semias April 22nd, 2011 @ 03:49 AM

    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>');
    
  • semias

    semias April 22nd, 2011 @ 05:28 AM

    • 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)

  • semias

    semias April 22nd, 2011 @ 08:08 AM

    • State changed from “open” to “resolved”

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Sitellite web content management system.

People watching this ticket

Pages