Go Back   SitePoint Forums > Forum Index > Program Your Site > Java and JSP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Mar 4, 2005, 10:15   #1
kiltman
SitePoint Addict
 
kiltman's Avatar
 
Join Date: Mar 2004
Location: scotland
Posts: 242
help with translation function

hello,

im currently coding a function to translate between languages,

however im having some problems, heres what i have so far

Code:
public String translateEngAndFreToSol(int option) //option = 0 for english, 1 for french
    {
        String[] data = loadSave.getLoadedData().split("\\s"); // creates array of words (by splitting string where theres a space)
        String output = "";
        String word = "";
        
        for(int i = 0; i < data.length; i++)
        {
            String prev = data[i]; //used to store data incase current word is not in mini dictionary

            try
            {
                switch(option)
                {
                    case 0: word = dictionary.getEntryByEngWord(data[i]).getSolWord();
                            break;
                    case 1: word = dictionary.getEntryByFreWord(data[i]).getSolWord();
                            break;
                }
                output += word + " ";  
            }
            catch(NullPointerException e)  //if word is not stored in the dictionary then use the value thats currently there, probally not best way to handle this
            {
                output += prev + " ";
            }   
        }
        return output.trim();
    }
with this function if the loaded data is:

Hello, how are you?

how do i get it to leave any grammer intact and only to translate the words?

any help at all would be greatly appreciated
kiltman is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 00:40.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved