Changeset 20012 for extensions


Ignore:
Timestamp:
Jan 9, 2013, 12:03:22 AM (12 years ago)
Author:
patdenice
Message:

Languages tags differentiate [lang=fr_FR] and [lang=fr_CA]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ExtendedDescription/main.inc.php

    r19840 r20012  
    3333  {
    3434    global $user;
    35     $user_lang = substr($user['language'], 0, 2);
    36   }
    37 
    38   if (!substr_count(strtolower($desc), '[lang=' . $user_lang . ']'))
     35    $user_lang = $user['language'];
     36  }
     37
     38  $small_user_lang = substr($user['language'], 0, 2);
     39
     40  if (!preg_match('#\[lang=('.$user_lang.'|'.$small_user_lang.')\]#i', $desc))
    3941  {
    4042    $user_lang = 'default';
    41   }
    42 
    43   if (substr_count(strtolower($desc), '[lang=' . $user_lang . ']'))
     43    $small_user_lang = 'default';
     44  }
     45
     46  if (preg_match('#\[lang=('.$user_lang.'|'.$small_user_lang.')\]#i', $desc))
    4447  {
    4548    // la balise avec la langue de l'utilisateur a été trouvée
    46     $patterns[] = '#(^|\[/lang\])(.*?)(\[lang=(' . $user_lang . '|all)\]|$)#is';
     49    $patterns[] = '#(^|\[/lang\])(.*?)(\[lang=(' . $user_lang . '|' . $small_user_lang . '|all)\]|$)#is';
    4750    $replacements[] = '';
    48     $patterns[] = '#\[lang=(' . $user_lang . '|all)\](.*?)\[/lang\]#is';
     51    $patterns[] = '#\[lang=(' . $user_lang . '|' . $small_user_lang . '|all)\](.*?)\[/lang\]#is';
    4952    $replacements[] = '\\1';
    5053  }
Note: See TracChangeset for help on using the changeset viewer.