Welcome Guest, Not a member yet? Register   Sign In
Pagination class and i18n, l10n & m17n
#1

[eluser]Victoria.G[/eluser]
I've been trying CI these days and I within those tests there was an output from a database that needed pagination, so I used the class.

I works fine BUT there are TWO issues regarding i18n and HTML-CSS formating:

i18n
The class variables

Code:
var $first_link           = '‹ First';
    var $next_link            = '>';
    var $prev_link            = '<';
    var $last_link            = 'Last ›';


need to be on a language file if you're to run a site in other language than English, or if you're to run a site in more than one language (I usually need to develop sites in two or three languages).

I included them in a file called "pagination_lang.php" in the language directory and changed the constructor to:

Code:
function CI_Pagination($params = array())
    {
        $this->CI =& get_instance();
    
        // Checks for lang file
        if ( ! in_array('pagination_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
        {
            $this->CI->lang->load('pagination');
        }

        if (count($params) > 0)
        {
            $this->initialize($params);
        }
        
        $this->first_link = $this->CI->lang->line('pag_first_link');
        $this->last_link = $this->CI->lang->line('pag_last_link');
        $this->next_link = $this->CI->lang->line('pag_next_link');
        $this->prev_link = $this->CI->lang->line('pag_prev_link');

        log_message('debug', "Pagination Class Initialized");
    }
The lang file, in Spanish could be:

Code:
<?php

$lang['pag_first_link'] = "primero";
$lang['pag_next_link'] = "siguiente";
$lang['pag_prev_link'] = "previo";
$lang['pag_last_link'] = "Ășltimo";

?>

and in English:

Code:
<?php

$lang['pag_first_link'] = "first";
$lang['pag_next_link'] = "next";
$lang['pag_prev_link'] = "previous";
$lang['pag_last_link'] = "last";

?>

The characters > < ‹ and › could be inserted as formating, what leads me to the

Formating

Enclosed in the class there are formatting options:
Code:
var $full_tag_open        = '';
    var $full_tag_close        = '';
    var $first_tag_open        = '';
    var $first_tag_close        = ' ';
    var $last_tag_open        = ' ';
    var $last_tag_close        = '';
    var $cur_tag_open        = '&nbsp;<b>';
    var $cur_tag_close        = '</b>';
    var $next_tag_open        = '&nbsp;';
    var $next_tag_close        = '&nbsp;';
    var $prev_tag_open        = '&nbsp;';
    var $prev_tag_close        = '';
    var $num_tag_open        = '&nbsp;';
    var $num_tag_close        = '';

Those should also be removed from the class if we are to allow reuse and specially if we want different pagination controls on our pages (it could happen), one showing just previous/next and one showing first/last, using different CSS classes for formatting output,...

I've not worked on that as far as I'm just beginning with CI and other priorities (warrant i18n for all classes) take precedence.

Best regards
#2

[eluser]xwero[/eluser]
I'm working on a replacement library. The first release you can find in this thread. Wiredesignz made it possible to put the pagination segment in the url where you want and i added a view file instead of defining the output with variables. It's on hold until i have another library out of the door but if you want to work on it be my guest.

It's good to have other people working with different languages because it's one of the areas that isn't worked out well.
#3

[eluser]Victoria.G[/eluser]
Yep, sorry for my confusion about where to post this... Just trying to figure everything out for the first time Wink

I'll be following your thread... now I'm on to full i18n and m17n (a multilanguage site is a must for me, where I live there are 2 official languages -Spanish and Catalan- and most of the projects requiere English as well). To really keep formatting out of the code is my second priority,... Wink
#4

[eluser]GSV Sleeper Service[/eluser]
I'm shocked to see a "b" tag in the library, I thought it was deprecated long ago
#5

[eluser]Victoria.G[/eluser]
It's not deprecated GSV Sleeper Service, it's just not recommended to use if you just want to give emphasis to the word (or phrase) and pretend visual impared visitors to your site be aware of the difference.

You can use <b> and <i> if you just want to add visual style with no special meaning. An example could be if you just wanted the first letter of your brand name to be displayed different... your brand still "sounds" the same, but it has different visualizations.

In the pagination class I don't really think it's necessary, <strong> would be more convenient Wink
But also &nbsp; should be replaced by some class selector so formatting is passed to the view and CSS.

In my own first use of the class I just set them as:

Code:
var $first_tag_open        = '<span class="label">';

    var $first_tag_close    = '</span>';

    var $last_tag_open        = '<span class="label">';

    var $last_tag_close        = '</span>';

    var $cur_tag_open        = '<span class="here">';

    var $cur_tag_close        = '</span>';

    var $next_tag_open        = '<span class="label">';

    var $next_tag_close        = '</span>';

    var $prev_tag_open        = '<span class="label">';

    var $prev_tag_close        = '</span>';

    var $num_tag_open        = '';

    var $num_tag_close        = '';




Theme © iAndrew 2016 - Forum software by © MyBB