Language Translator in android [ HELP ] !!!!!

Tutorials with advanced 'difficulty' and more Lines of Code.

Language Translator in android [ HELP ] !!!!!

Postby Sivan » Fri Jul 09, 2010 6:32 pm

Hi..

I want to create a Language translator for android

and can someone give me a tutorial on this....

I have made my layout on this ....

I have the CODE on the layout .....

_________________________________________________________________________________________________
Values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Translate!</string>
<string name="app_name">Translate</string>
<string name="from_text">Language</string>
<string name="original_text">Enter Your Text !</string>
<string name="to_text">Select the language of conversion </string>
<string name="translated_text">Your translated text is....</string>
<string name="back_text">Please wait</string>

</resources>
___________________________________________________________________________________________

_________________________________________________________________________________________________
:D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D :D
_________________________________________________________________________________________________
:) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :)

_________________________________________________________________________________________________
layout/main.xml


<?xml version="1.0" encoding="utf-8"?>
<ScrollView

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TableLayout

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1"
android:padding="10dip">

<TableRow>
<TextView android:text="@string/from_text" />
<Spinner android:id="@+id/from_language" />
</TableRow>
<EditText
android:id="@+id/original_text"
android:hint="@string/original_text"
android:padding="10dip"
android:textSize="18sp" />
<TableRow>

<TextView android:text="@string/to_text" />

<Spinner android:id="@+id/to_language" />

</TableRow>

<TextView
android:id="@+id/translated_text"
android:padding="10dip"
android:textSize="18sp" />

<TextView android:text="@string/back_text" />

<TextView
android:id="@+id/retranslated_text"
android:padding="10dip"
android:textSize="18sp" />
</TableLayout>
</ScrollView>

_____________________________________________________________________________________________
_____________________________________________________________________________________________
______________________________________________________________________________________________

Values/arrays.xml ( for the LANGUAGES )

<?xml version="1.0" encoding="utf-8" ?>

<resources>

<array name="languages">
<item>Bulgarian (bg)</item>
<item>Chinese Simplified (zh-CN)</item>
<item>Chinese Traditional (zh-TW)</item>
<item>Catalan (ca)</item>
<item>Croatian (hr)</item>
<item>Czech (cs)</item>
<item>Danish (da)</item>
<item>Dutch (nl)</item>
<item>English (en)</item>
<item>Filipino (tl)</item>
<item>Finnish (fi)</item>
<item>French (fr)</item>
<item>German (de)</item>
<item>Greek (el)</item>
<item>Indonesian (id)</item>
<item>Italian (it)</item>
<item>Japanese (ja)</item>
<item>Korean (ko)</item>
<item>Latvian (lv)</item>
<item>Lithuanian (lt)</item>
<item>Norwegian (no)</item>
<item>Polish (pl)</item>
<item>Portuguese (pt-PT)</item>
<item>Romanian (ro)</item>
<item>Russian (ru)</item>
<item>Spanish (es)</item>
<item>Serbian (sr)</item>
<item>Slovak (sk)</item>
<item>Slovenian (sl)</item>
<item>Swedish (sv)</item>
<item>Ukrainian (uk)</item>

</array>
</resources>

Help will be appricieated.....
:| :| :| :| :|
Sivan
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Jul 05, 2010 10:02 am
Location: Bangalore , India

Top

Re: Language Translator in android [ HELP ] !!!!!

Postby the_1danta » Fri Oct 08, 2010 8:43 am

Hiii !!!!

You have to create folder "Values-fr"---for freanch---"values-it"---for Italian and then withen there (String.xml)--you have to put the string------exm...
For Italy(res/values-it/string.xml)

<string name="no">Non</string>

For Freanch(res/values-fr/string.xml)
<string name="no">No</string>


In main activity.java

button b=(Button)finfviewById(R.id.b);
b.setText(R.string.no);

---------- Now change the language from phone to see the changes---------

Regards
Rajdeep
the_1danta
Freshman
Freshman
 
Posts: 4
Joined: Thu Oct 07, 2010 6:40 am

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests