Transliteration is not always obvious

Report a typo

In our service, users can register names in different languages, but we want to use only English for display in internal systems. The following function will return a translated character or None if the character has no obvious translation.

def findTransliteration(letter: Char): Option[Char]

We need to implement a function that will take a string in a different language and return a translated string. All untranslatable characters must be skipped.

Find a higher-order method of the String type to help with this.

Sample Input 1:

Юрій

Sample Output 1:

Uri
Write a program in Scala 3
def translate(name: String): String =
name.???(findTransliteration).mkString
___

Create a free account to access the full topic