Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Greeklish / Greekglish
- Search : https://github.com/search?p=2&q=greeklish&type=Repositories
- ===========PHP============
- PHP : https://gist.github.com/teomaragakis/7580134
- https://github.com/konmavrakis/greek_to_greeklish/blob/master/script.php
- https://github.com/piliop/togreeklish ++
- //Replace Greek Chars with english
- function greeklish($str) {
- //FIDE pre-process (here we put exceptions we might need)
- // $greek = array('ΧΡ','Υ','Ύ');
- // $english = array('CHR','U','U');
- // $str = str_replace($greek, $english, $str);
- //letter
- $greek = array('α','ά','Ά','Α','β','Β','γ','Γ','δ','Δ','ε','έ','Ε','Έ','ζ','Ζ','η','ή','Η','θ','Θ',
- 'ι','ί','ϊ','ΐ','Ι','Ί','κ','Κ','λ','Λ','μ','Μ','ν','Ν','ξ','Ξ','ο','ό','Ο','Ό','π','Π','ρ','Ρ','σ',
- 'ς','Σ','τ','Τ','υ','ύ','Υ','Ύ','φ','Φ','χ','Χ','ψ','Ψ','ω','ώ','Ω','Ώ',' ');
- $english = array('a', 'a','A','A','b','B','g','G','d','D','e','e','E','E','z','Z','i','i','I','th','Th',
- 'i','i','i','i','I','I','k','K','l','L','m','M','n','N','x','X','o','o','O','O','p','P' ,'r','R','s',
- 's','S','t','T','u','u','Y','Y','f','F','x','X','ps','Ps','o','o','O','O',' ');
- $string = str_replace($greek, $english, $str);
- return $string;
- }
- ===========Python 3 (help from chatgpt)===============
- import os
- def custom_unidecode(char):
- # Προσαρμογή της unidecode για ειδικές αντιστοιχίες
- from_chars = ["ου", "ΟΥ", "Ού", "ού", "αυ", "ΑΥ", "Αύ", "αύ", "ευ", "ΕΥ", "Εύ", "εύ", "α", "Α", "ά", "Ά", "β", "Β", "γ", "Γ", "δ", "Δ", "ε", "Ε", "έ", "Έ", "ζ", "Ζ", "η", "Η", "ή", "Ή", "θ", "Θ", "ι", "Ι", "ί", "Ί", "ϊ", "ΐ", "Ϊ", "κ", "Κ", "λ", "Λ", "μ", "Μ", "ν", "Ν", "ξ", "Ξ", "ο", "Ο", "ό", "Ό", "π", "Π", "ρ", "Ρ", "σ", "Σ", "ς", "τ", "Τ", "υ", "Υ", "ύ", "Ύ", "ϋ", "ΰ", "Ϋ", "φ", "Φ", "χ", "Χ", "ψ", "Ψ", "ω", "Ω", "ώ", "Ώ"]
- to_chars = ["ou", "ou", "ou", "ou", "au", "au", "au", "au", "eu", "eu", "eu", "eu", "a", "a", "a", "a", "b", "b", "g", "g", "d", "d", "e", "e", "e", "e", "z", "z", "i", "i", "i", "i", "th", "th", "i", "i", "i", "i", "i", "i", "i", "k", "k", "l", "l", "m", "m", "n", "n", "ks", "ks", "o", "o", "o", "o", "p", "p", "r", "r", "s", "s", "s", "t", "t", "y", "y", "y", "y", "y", "y", "y", "f", "f", "x", "x", "ps", "ps", "o", "o", "o", "o"]
- # Αντικατάσταση ειδικών χαρακτήρων
- replacements = dict(zip(from_chars, to_chars))
- return replacements.get(char, char)
- def rename_files():
- current_directory = os.getcwd()
- for filename in os.listdir(current_directory):
- if os.path.isfile(os.path.join(current_directory, filename)):
- # Αντικατάσταση ελληνικών χαρακτήρων με greekglish
- new_filename = ''.join(custom_unidecode(char) for char in filename)
- # Μετονομασία του αρχείου
- os.rename(os.path.join(current_directory, filename), os.path.join(current_directory, new_filename))
- print(f'Renamed: {filename} -> {new_filename}')
- if __name__ == "__main__":
- rename_files()
- ===========JAVASCRIPT===============
- JS : https://gist.github.com/kostasx/7516158
- https://github.com/papasavva/Greeklish2Greek/blob/master/converter.js
- https://github.com/kostasxyz/greeklish
- https://github.com/kostasxyz/Skp-Greeklish-Slugs
- https://github.com/attheodo/greeklishify/blob/master/greeklishify.js
- JAVASCRIPT
- function string_to_slug(str) {
- //https://gist.github.com/kostasx/7516158
- str = str.replace(/^\s+|\s+$/g, '') // TRIM WHITESPACE AT BOTH ENDS.
- .toLowerCase(); // CONVERT TO LOWERCASE
- const from = [ "ου", "ΟΥ", "Ού", "ού", "αυ", "ΑΥ", "Αύ", "αύ", "ευ", "ΕΥ", "Εύ", "εύ", "α", "Α", "ά", "Ά", "β", "Β", "γ", "Γ", "δ", "Δ", "ε", "Ε", "έ", "Έ", "ζ", "Ζ", "η", "Η", "ή", "Ή", "θ", "Θ", "ι", "Ι", "ί", "Ί", "ϊ", "ΐ", "Ϊ", "κ", "Κ", "λ", "Λ", "μ", "Μ", "ν", "Ν", "ξ", "Ξ", "ο", "Ο", "ό", "Ό", "π", "Π", "ρ", "Ρ", "σ", "Σ", "ς", "τ", "Τ", "υ", "Υ", "ύ", "Ύ", "ϋ", "ΰ", "Ϋ", "φ", "Φ", "χ", "Χ", "ψ", "Ψ", "ω", "Ω", "ώ", "Ώ" ];
- const to = [ "ou", "ou", "ou", "ou", "au", "au", "au", "au", "eu", "eu", "eu", "eu", "a", "a", "a", "a", "b", "b", "g", "g", "d", "d", "e", "e", "e", "e", "z", "z", "i", "i", "i", "i", "th", "th", "i", "i", "i", "i", "i", "i", "i", "k", "k", "l", "l", "m", "m", "n", "n", "ks", "ks", "o", "o", "o", "o", "p", "p", "r", "r", "s", "s", "s", "t", "t", "y", "y", "y", "y", "y", "y", "y", "f", "f", "x", "x", "ps", "ps", "o", "o", "o", "o" ];
- for ( var i = 0; i < from.length; i++ ) {
- while( str.indexOf( from[i]) !== -1 ){
- str = str.replace( from[i], to[i] ); // CONVERT GREEK CHARACTERS TO LATIN LETTERS
- }
- }
- str = str.replace(/[^a-z0-9 -]/g, '') // REMOVE INVALID CHARS
- .replace(/\s+/g, '-') // COLLAPSE WHITESPACE AND REPLACE BY DASH -
- .replace(/-+/g, '-'); // COLLAPSE DASHES
- return str;
- }
- ---------- Forwarded message ---------
- From: giannos toula <giatoula@gmail.com>
- Date: Wed, Mar 20, 2013 at 10:58 PM
- Subject: greekglish_v09_20130320a.php
- To: JohnTrister.edu <trister12@yahoo.com>, JJ M <johnmail0+mycode@gmail.com>, <johnmail0@yahoo.gr>
- greekglish_v09_20130320a.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement