Advertisement:

Author Topic: Search in greek and english characters - Latin Transliteration..  (Read 366 times)

officeland

  • Newbie
  • *
  • Posts: 15
Search in greek and english characters - Latin Transliteration..
« on: February 14, 2019, 11:25:45 pm »
Please i need help,

I want when i do search in City field and i write latin - english characters to replace with greek ones.
Example: when i type "volos" to replace with "βολος".

So i where i have to include the Latin Transliteration..
i found this on the forum that is for Russian alfabet
https://forums.osclass.org/development/bug-with-ads-please-help

Code: [Select]
<?php
function cust_cyrillic_to_latin($textcyr) {
    
$cyr  = array('а','б','в','г','д','e','ж','з','и','й','к','л','м','н','о','п','р','с','т','у',
        
'ф','х','ц','ч','ш','щ','ъ','ь''ю','я','А','Б','В','Г','Д','Е','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У',
        
'Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь''Ю','Я' );
    
$lat = array( 'a','b','v','g','d','e','zh','z','i','y','k','l','m','n','o','p','r','s','t','u',
        
'f' ,'h' ,'ts' ,'ch','sh' ,'sht' ,'a' ,'y' ,'yu' ,'ya','A','B','V','G','D','E','Zh',
        
'Z','I','Y','K','L','M','N','O','P','R','S','T','U',
        
'F' ,'H' ,'Ts' ,'Ch','Sh' ,'Sht' ,'A' ,'Y' ,'Yu' ,'Ya' );

    return 
str_replace($cyr$lat$textcyr); 
}
?>

Do i need keep $cyr and $lat or need greek other code??
Can someone please inform how do that?
need put in functions.php of theme or inc.search.php ?
« Last Edit: February 15, 2019, 06:53:07 pm by officeland »

elizabeth

  • Newbie
  • *
  • Posts: 37
Re: Search in greek and english characters - Latin Transliteration..
« Reply #1 on: February 16, 2019, 05:20:22 pm »
Please i need help,

I want when i do search in City field and i write latin - english characters to replace with greek ones.
Example: when i type "volos" to replace with "βολος".

So i where i have to include the Latin Transliteration..
i found this on the forum that is for Russian alfabet
https://forums.osclass.org/development/bug-with-ads-please-help

Code: [Select]
<?php
function cust_cyrillic_to_latin($textcyr) {
    
$cyr  = array('а','б','в','г','д','e','ж','з','и','й','к','л','м','н','о','п','р','с','т','у',
        
'ф','х','ц','ч','ш','щ','ъ','ь''ю','я','А','Б','В','Г','Д','Е','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У',
        
'Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ь''Ю','Я' );
    
$lat = array( 'a','b','v','g','d','e','zh','z','i','y','k','l','m','n','o','p','r','s','t','u',
        
'f' ,'h' ,'ts' ,'ch','sh' ,'sht' ,'a' ,'y' ,'yu' ,'ya','A','B','V','G','D','E','Zh',
        
'Z','I','Y','K','L','M','N','O','P','R','S','T','U',
        
'F' ,'H' ,'Ts' ,'Ch','Sh' ,'Sht' ,'A' ,'Y' ,'Yu' ,'Ya' );

    return 
str_replace($cyr$lat$textcyr); 
}
?>

Do i need keep $cyr and $lat or need greek other code??
Can someone please inform how do that?
need put in functions.php of theme or inc.search.php ?

Hi @officeland. It doesn't matter. They are only variables so you can change them from $cyr to $gr for example and replace the Cyrillic letters with Greek.

"Αυτή η λύση ομως που βρήκες στο forum μετατρέπει τους κυριλικους χαρακτήρες σε λατινικους και δεν θα σε βοηθήσει στη αναζήτηση όπως εσυ χρειάζεσαι και έγραψες παραπάνω.

Στη θέση σου θα έγραφα ενα script σε javascript to οποιο θα μετέτρεπε τους χαρακτήρες απο λατινικους σε ελληνικούς οταν καποιος γραφει μεσα στο search field. To είχα κανει παλιότερα και δουλεψε μια χαρά. "

PS ---> Απο Βόλο εισαι ?? :)
« Last Edit: February 16, 2019, 05:24:57 pm by elizabeth »

officeland

  • Newbie
  • *
  • Posts: 15
Re: Search in greek and english characters - Latin Transliteration..
« Reply #2 on: February 16, 2019, 11:28:16 pm »
Καλησπέρα !!! όχι, παράδειγμα ο Βόλος :)

Έχεις να μου δώσεις παραπάνω οδηγίες μιας και το έχεις κάνει να με βοηθήσεις?


officeland

  • Newbie
  • *
  • Posts: 15
Re: Search in greek and english characters - Latin Transliteration..
« Reply #3 on: February 20, 2019, 12:20:48 pm »
Anyone that can help me???

« Last Edit: February 23, 2019, 09:51:12 pm by officeland »