Last active
March 6, 2022 21:33
-
-
Save yunusemre002/eee6c4e261934c91a2aa4468195c34e9 to your computer and use it in GitHub Desktop.
js-turkish-to-english.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It converts all lowercase or uppercase Turkish characters to English one on given text. | |
String.prototype.turkishToEnglish = function () { | |
return this | |
.replace(/Ğ/g, "G") | |
.replace(/ğ/g, "g") | |
.replace(/Ü/g, "U") | |
.replace(/ü/g, "u") | |
.replace(/Ş/g, "S") | |
.replace(/ş/g, "s") | |
.replace(/İ/g, "I") | |
.replace(/ı/g, "i") | |
.replace(/Ö/g, "O") | |
.replace(/ö/g, "o") | |
.replace(/Ç/g, "C") | |
.replace(/ç/g, "c"); | |
}; | |
// //Example | |
// let text = 'Şinasi bu akşam sağa sola çağrı atıp durdu. Bu Çocuk neden böyle... ğğĞĞÜÜüüŞŞşşÖÖööÇÇçç'; | |
// console.log(text.turkishToEnglish()) | |
// //output: Sinasi Bu aksam saga sola cagri atip durdu. Bu Cocuk neden boyle... ggGGUUuuSSssOOooCCcc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment