Internationalization

sovietfunk - June 14, 2007 - 13:52
Project:Views Alpha Pager
Version:5.x-1.4
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:active
Description

Has anyone looked into internationalization of views_alpha_pager?
Specifically, I will be looking into adding Norwegian letters, which should be listed after the end of the English alphabet: Æ Ø Å. This should also be of interest to Swedish/German users: Ä Ö et cetera. I will be posting this to norwegian drupal sites as well.

#1

douggreen - June 14, 2007 - 13:58

VAP gets the first character from the list and uses ctype_alpha to determine if it is an alpha character. The php document for ctype_alpha mentions other languages, so I'm not sure that this doesn't work as-is. Have you tried it?

#2

sovietfunk - June 14, 2007 - 14:54

I have tried putting in "setlocale(LC_ALL, 'nb_NO');" directly in views_alpha_pager.module but still my characters are not recognized by ctype_alpha. (Where if anywhere does drupal core apply setlocale()?)
I have also tried other variations on the locale identifier.
I have also tried various settings under the Administration->localization menus.
Just now I am trying to confirm that my server actually fully supports my locale.

Apart from that, here is what I've tried changing so far. I may have lost track of linenumbers but i can make another pass and get the correct ones when this is done.
Note that I haven't replaced special characters with codes.

views_alpha_pager.module:
171: if ($item_display >= 'A' && $item_display <= 'Å') {
186: $where = "INSTR('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ', $myfield) = 0";

The last lines generated a collation locale conflict error (something like that) from mysql until i changed collation for the sort table in mysql. It was latin1_swedish_ci. No errors with utf8_unicode_ci.

#3

sovietfunk - June 14, 2007 - 15:24

Sorry, I just confirmed that my server (incredibly!) doesn't support my locale / or doesn't support setting the locale.
This should be essential as it messes up a lot of things... And it's strange since my server is operated by a norwegian firm.
I will return here if it doesn't work after they've implemented the locale, otherwise this can be considered moot.

#4

sovietfunk - June 15, 2007 - 22:43

Ok, my server does have an available locale which should work. (Norway: One country, three locale codes, beat that...)
The problem now is where to apply setlocale(LC_ALL, "no_NO.UTF-8")? I tried setting it in the module, but still the same outcome as before.

I searched the drupal core, and have found setlocale applied only one place, includes/unicode.inc:43
Here it applies the locale "C" for ctype:

// Set the standard C locale to ensure consistent, ASCII-only string handling.
setlocale(LC_CTYPE, 'C');

If this is the only place where the locale is set, ctype_alpha() checking with other locales is defeated in VAP.

I don't know how or where to proceed from here... Is this problem beyond the scope of VAP?

#5

makbeta - July 11, 2007 - 04:52

Was anyone able find a successful workaround for the Internationalization problem?
I'm trying to use it on node with Cyrillic title & getting a complete blank instead of an alphabet. Any input would be greatly appreciated.
Thanks.

#6

lazyant - July 14, 2007 - 16:28

I have the same problem with Cyrillic title.

#7

douggreen - July 14, 2007 - 17:11

Does anyone have a test case for me?

#8

sovietfunk - July 24, 2007 - 19:53

I cheated my way around this by copying theme_alpha_pager function from the module into my template and doing my changes there. I also added a complete alphabet so i could display empty letters as well. What i did to display the Norwegian character results was to replace the "_"-value with the needed characters. Here's the function as i use it:

function zen_alpha_pager($items, $current = '', $path = '', $query = '') {
  // add style sheet
  $modpath = drupal_get_path('module', 'views_alpha_pager');
  drupal_add_css($modpath .'/views_alpha_pager.css', 'module');

  $alphabet = array(
  "A" => "A",
  "B" => "B",
  "C" => "C",
  "D" => "D",
  "E" => "E",
  "F" => "F",
  "G" => "G",
  "H" => "H",
  "I" => "I",
  "J" => "J",
  "K" => "K",
  "L" => "L",
  "M" => "M",
  "N" => "N",
  "O" => "O",
  "P" => "P",
"Q" => "Q",
  "R" => "R",
  "S" => "S",
  "T" => "T",
  "U" => "U",
  "V" => "V",
  "W" => "W",
  "X" => "X",
  "Y" => "Y",
  "Z" => "Z",
  "_" => "ÆØÅ",
  "*" => t('All'));
  $itemdiff = array_diff($alphabet, $items);

  $output = '';

  if (!empty($items)) {
    $output .= '<div class="apager"><span class="pager-list">';
    foreach ($alphabet as $item => $item_display) {
if (in_array("$item", $items) || $item_display == t('All')) {
if ("$item" == "$current") {
$output .= '<strong class="pager-current">'. $item_display .'</strong> ';
}
else {
if ($item < $current) {
$class = 'pager-previous';
}
else {
$class = 'pager-next';
}
$output .= zen_alpha_pager_link($item, $item_display, array('class' => $class), $path, $query);
}
$output .= ' ';
} else {
$output .= '<span class="pager-empty">'. $item_display .'</span> ';
}
    }
    $output .= '</span></div>';
    return $output;
  }
}

If you don't want the full alphabet, i guess you can copy the function from the module (and rename it to your theme) and insert

if (array_key_exists("_",$items) {
items["_"] = "ÆØÅ";
}

before the foreach loop. If i wasn't procrastinating already i would test if this actually works. This is just a compromise workaround. My real problem was setting the locale properly, which I still don't know if I've gotten around. Look at comment #4 under this issue.

#9

makbeta - July 28, 2007 - 17:47

douggreen,

Here's an example: http://belmova.org/slovy2

I'm trying to get a list display items according to the following alphabet:
http://www.pravapis.org/art_belarusian_alphabet.asp

Please let me know if you need anything else.
I'd be more than happy to help with testing, etc.

Thank you.

#10

player_ - February 27, 2008 - 22:04

I have a problem with Cyrillic too.

#11

player_ - April 13, 2008 - 16:18

#12

yngvewb - July 2, 2008 - 09:20

I’m also from Norway and encountered the same problem.
My suggestion is that Views Alpha Pager module should, as a quick fix to the problem, change line 176 in views_alpha_pager.module:

<?php
$items
['_'] = '_';
?>

to
<?php
$items
['_'] = t('Others');
?>

With the locale module it’s easy to replace "Others" it with for example "ÆØÅ" .

#13

stilblütler - July 9, 2008 - 08:34
Version:5.x-1.x-dev» 5.x-1.4
Category:support request» feature request
Priority:normal» critical

I have the same problem here in Austria. As mentioned in the initial post it is a problem in the German language.

But the sort works as follows (different, than mentioned above):

There are the basic 26 roman letters (lowercase: a to z / uppercase: A to Z) and the 3 extra letters, the Umlauts (ä, ö, ü / Ä, Ö, Ü) and the sharp s (ß -- only lowercase, because it can never occur at the beginning of a word). In addition there can occur accented characters, but only in proper names (like á/Á, ž/Ž, ç/Ç, etc.).
See http://en.wikipedia.org/wiki/German_alphabet

I have the printed German dictionary "Duden" in front of me, and the index only consists of the 26 roman letters A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. A word like "Österreich" (German name for Austria) is listed under "O", as if the "Ö" would be a "O" (Osterreich). There is *no* extra index tab for Ä, Ö and Ü.

[...]
Ostermontag (Easter Monday)
Osterpinze (special austrian Easter bakery)
Österreich (Austria)
österreichisch (austrian)
österreichisch-ungarisch (austrian-hungarian)
Ostersonntag (Easter Sunday)
[...]

This is the sort, expected by any German speaking user. Therefore the Views Alpha Pager should behave the same way.

To make the sort system work correctly there has the be an assignment list for all special characters, like Ä = "A", Ö = "O", Ü = "U", ß = "s", Á = "A" or Ž = "Z", to define under which index letter they need to be sorted.

This is exactly what the module pathauto does with the file "i18n-ascii.txt" (http://drupal.org/project/pathauto). Due to the usage of this translation table, pathauto also works perfect with the Cyrillic alphabet, as far as I know.

I am a designer, and no programmer. But for Views Alpha Pager to become perfectly and more flexibly internationalised, maybe a solution like pathauto would be considerable.

#14

stilblütler - July 29, 2008 - 17:18

Isn’t there anybody else out there having the same problem?
Does someone have an idea how to solve this problem?
Is there any work in progress? (for Drupal 5 or Drupal 6? >> #279907: Port Views Alpha Pager to D6)

Thanks for any reply!

 
 

Drupal is a registered trademark of Dries Buytaert.