Hello guys i have started project that i want to translate text from Latin to Cyrillic so i have just this and i dont know how to continue any help will be appreciated
- Thanks :)

private void TranslateActionPerformed(java.awt.event.ActionEvent evt) { 

        String TextToTranslate = textToTranslate.getText();
        char[] latinica = {
        char[] kirilica = {
        for (int l = 0; l < latinica.length; l++) {
            char la = latinica[l];
4 Years
Discussion Span
Last Post by StefanRafa0

don't really understand what you're trying to do here. especially since you can't translate words letter by letter.

for instance:

brand (the dutch word for fire)
feuer (the german word for fire)
incendie (the french word for fire)

this should show you two reasons why it wouldn't work:

1 the words are not the same length


as you can see: less than a total translation

2 just because one language has different letters, doesn't mean the other does


so, in this word, both i and e are 'translated' by e, but that's just for this particular word (and, again, the length isn't equal)

Edited by stultuske


Do you really mean "translate"? - in which case see stultuske's post
Or do you mean "transliterate" - replace each letter by it's nearest cyrillic equivalent regardless of meaning, in which case you could use something like this pseudo-code:

for each letter in the original string
   find that letter in the latinica array, remember its index
   get the  letter from the kirilica array at that same index
   append that letter to the output string

(There are other ways to approach this - eg use the input character's numeric value as an index into a single array of cyrillic equivalents, or create a Map with latin letters as keys and cyrillic letters as the values, but your approach is OK)

Edited by JamesCherrill

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.