"The application that I've been assigned to had a fairly common requirement", writes Shaun H. "It needed to be bilingual, supporting both French and English."
"I've worked on quite a few multilingual apps before, and have a lot of different patterns and anti-patterns, ranging from using a resource file for strings to copy/paste/translate. Now, I can add this Oracle-based function to the list."
function translate_to_french( p_words in Varchar2 ) return varchar2 as begin return replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( replace( lower(p_words) , ' and ' , ' et ' ) , 'dollars' , 'dollars' ) , 'cents' , 'cents' ) , 'duodecillion' , 'bidecillion' ) , 'quintillion' , 'cintillion' ) , 'billion' , 'milliard' ) , 'thousand' , 'mille' ) , 'hundred' , 'cent' ) , 'ninety' , 'quatre-vingt-dix') , 'eighty' , 'quatre-vingts' ) , 'seventy' , 'soixante-dix' ) , 'sixty' , 'soixante' ) , 'fifty' , 'cinquante' ) , 'forty' , 'quarante' ) , 'thirty' , 'trente' ) , 'twenty' , 'vingt' ) , 'nineteen' , 'dix-neuf' ) , 'eighteen' , 'dix-huit' ) , 'seventeen' , 'dix-sept' ) , 'sixteen' , 'seize' ) , 'fifteen' , 'quinze' ) , 'fourteen' , 'quatorze' ) , 'thirteen' , 'treize' ) , 'twelve' , 'douze' ) , 'eleven' , 'onze' ) , 'ten' , 'dix' ) , 'nine' , 'neuf' ) , 'eight' , 'huit' ) , 'seven' , 'sept' ) , 'six' , 'six' ) , 'five' , 'cinq' ) , 'four' , 'quatre' ) , 'three' , 'trois' ) , 'two' , 'deux' ) , 'one' , 'un' ) , 'dix-six' , 'seize' ) , 'dix-cinq' , 'quinze' ) , 'dix-quatre' , 'quatorze' ) , 'dix-trois' , 'treize' ) , 'dix-deux' , 'douze' ) , 'dix-un' , 'onze' ) , '-un ' , '-une ' ) , 'un cent' , 'cent' ) , 'un mille' , 'mille' ) , 'une' , 'un' ) , 'soixante-onze' , 'soixante et onze') , 'quatre-vingts-' , 'quatre-vingt-' ) , '-un' , ' et un' ) , 'quatre-vingt et un', 'quatre-vingt-un' ) ; End translate_to_french;
Shaun adds, "at least we're handling the French translation of 'duodecillion' — you never know when you'll need to translate that."
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!