Index and cyrillic alphabet

perfectsense - November 8, 2009 - 09:05
Project:Bibliography Module
Version:6.x-1.7
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

How can i make index like this: ААБВГДЕЖЗ...... instead of ABCDEF.... ?

#1

rjerome - November 8, 2009 - 13:48

This is generated by the theme_biblio_alpha_line() function in the biblio_theme.inc file on lines 1023 to 1030 like this...

  for ($i = 65; $i <= 90; $i++) {
    if ($i == ord($current)){
      $output .= '<b>['.chr($i).']</b>&nbsp;';
    }
    else{
      $output .= l(chr($i), $path. chr($i), $options) .'&nbsp;';
    }
  }

If you were to wrap the "chr($i)" calls in t() then add the letters A thru Z to your translation file it should work. So you new code would look like this...

  for ($i = 65; $i <= 90; $i++) {
    if ($i == ord($current)){
      $output .= '<b>['.t(chr($i)).']</b>&nbsp;';
    }
    else{
      $output .= l(t(chr($i)), $path. (chr($i), $options) .'&nbsp;';
    }
  }

Let me know if this works and if it does, I'll put it in the code.

Ron.

#2

perfectsense - November 8, 2009 - 18:15

then add the letters A thru Z to your translation file

Sorry, i can't understand that. My translation file (biblio-6.x-1.7.ru.po) contain strings like this:

#: biblio.module:779
msgid "Edit keyword information"
msgstr "Редактировать ключевые слова"

and not contain any alphabet symbols like ABCDE...
Where can i add letters A thru Z ?

#3

rjerome - November 8, 2009 - 22:14

This is probably not the best way to do this, but lets just call it a proof of concept...

you would have to add (at the end of the file) lines like

msgid "A"
msgstr "A"

msgid "B"
msgstr "Б"

msgid "B"
msgstr "Б"

.... and so on for each character, but I guess this might not be the best solution since there is not a one to one correspondence between the Latin and Cyrillic character sets.

#4

perfectsense - November 10, 2009 - 12:30

No, it's not working. When i insert this code:

  for ($i = 65; $i <= 90; $i++) {
    if ($i == ord($current)){
      $output .= '<b>['.t(chr($i)).']</b>&nbsp;';
    }
    else{
      $output .= l(t(chr($i)), $path. (chr($i), $options) .'&nbsp;';
    }
  }

i see only blank screen in Firefox and error 404 in Opera.

#5

rjerome - November 10, 2009 - 14:13

Opps, I hadn't actually tried that code, but it looks like there is a syntax error in the second "$output .= " line, it should be

$output .= l(t(chr($i)), $path. t(chr($i)), $options) .'&nbsp;';

#6

perfectsense - November 10, 2009 - 16:18

Yes, it's working. But this:

there is not a one to one correspondence between the Latin and Cyrillic character sets.

is too bad. (((
Thank you very much.
Sorry, can i ask you another question? Is there a way to place index with two rows of letters? like this:
ABCDEFGH......
АБВГДЕЖЗ.....

#7

rjerome - November 10, 2009 - 16:23

I'll see if I can come up with a more elegant solution which includes all Cyrillic characters.

Did mean that you want to have both Latin and Cyrillic lines?

#8

perfectsense - November 10, 2009 - 16:34

Yes, both Latin and Cyrillic lines. Thank you.

 
 

Drupal is a registered trademark of Dries Buytaert.