1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
String [] motsFR = {"contact","ressenti","cerveau","fermes tes yeux"};
String [] motsEN = {"touch", "feeling", "brain", "close your eyes"};
String citation = "La drogue, faut pas toucher, c'est sérieux... Moi j'ai touché, j'ai perdu le contact, j'avais plus le ressenti de la vie... Mon cerveau était à l'envers dans ma tête. La drogue, c'est comme quand tu fermes tes yeux et que tu traverses la rue...";
String[] mots = citation.split(" ");
for (int i=0; i< mots.length; i++) {
for (int j=0; j< mots.length; j++) {
if (mots[i].equals(motsFR[j])) {
citation = citation.replaceAll(motsFR[j], motsEN[i]);
}
System.out.print(citation);
}
}
}
} |