LANGUAGE TRANSLATOR APP Report
LANGUAGE TRANSLATOR APP Report
LANGUAGE TRANSLATOR APP Report
Bachelor of Engineering
in
Information Science and Engineering
Submitted by
RAYAN BHATTACHARJEE SALONI KUMARI SHIVAM PALIWAL
CERTIFICATE
This is to certify that the mini project report entitled LANGUAGE TRANSLATOR APP has
been successfully completed by RAYAN BHATTACHARJEE bearing USN 1RN18IS085,
SALONI KUMARI bearing USN 1RN18IS090 and SHIVAM PALIWAL bearing USN
1RN18IS099 , presently VI semester students of RNS Institute of Technology in partial
fulfillment of the requirements as a part of the Mobile Application Development Laboratory
(18CSMP68) for the award of the degree of Bachelor of Engineering in Information Science
and Engineering under Visvesvaraya Technological University, Belagavi during academic
year 2020–2021. It is certified that all corrections/suggestions indicated for Internal
Assessment have been incorporated in the report and deposited in the departmental library. The
mini project report has been approved as it satisfies the academic requirements as a part of
Mobile Application Development Laboratory.
External Viva
Name of the Examiners Signature with date
1. _________________________ _________________________
2. _________________________ __________________________
Abstract
I
Acknowledgment
The fulfillment and rapture that go with the fruitful finishing of any assignment would be
inadequate without the specifying the people who made it conceivable, whose steady direction
and support delegated the endeavors with success.
We would like to express our thanks to our Principal Dr. M K Venkatesha for his
support and inspired us towards the attainment of knowledge.
We wish to place on record our words of gratitude to Dr. Suresh L, Professor and
Head of the Department, Information Science and Engineering, for being the enzyme and
master mind behind our Mobile Application Development Laboratory with Mini Project
Work.
We would like to express our profound and cordial gratitude to my Mini Project Coordinators,
Ms. Sowmya S K and Mrs. Chandan Rani S R, Assistant Professors, Department of
Information Science and Engineering for their valuable guidance, constructive comments,
continuous encouragement throughout the Mini Project Work and guidance in preparing
report.
We would like to thank all other teaching and non-teaching staff of Information
Science & Engineering who have directly or indirectly helped us to carry out the Mini Project
Work.
Also we would like to acknowledge and thank our parents who are source of
inspiration and instrumental in carrying out this Mini Project Work.
Table of Contents
Certificate
Abstract i
Acknowledgment ii
List Of Figures vi
Abbreviations ix
1. Introduction To Android
1.1 History
1.2 Android Versions
1.3 Architecture Of Android
1.4 Android Studio Installation
2. Introduction To Project
2.1 Overview Of The Project
2.2 Aim Of The Project
3. System Design
4. Implementation
5. Testing
6. Results
7. Conclusion And Future Enhancements
References
iii
In chapter 1, details of Android.
In chapter 2, details of your project.
In chapter 3 , you add details of User interface (Xml code + initial UI screen shot) .
In chapter 4 , add details of your java code, ( put code and after each function in java give 4-5
lines of description of that function) . In chapter 5, Testing details along with test cases with
respect to your output.
In chapter 6, results , screenshots which gives you complete details of execution of your
project step by step.
In 7, Conclusion and future enhancements and finally give references
Android is an operating system and programming platform developed by Google for mobile
phones and other mobile devices, such as tablets. It can run on many different devices from
many different manufacturers. Android includes a software development kit (SDK) that helps
you write original code and assemble software modules to create apps for Android users.
Android also provides a marketplace to distribute apps. All together, Android represents
an ecosystem for mobile apps.
As the world's most popular mobile platform, Android powers hundreds of millions of mobile
devices in more than 190 countries around the world. It has the largest installed base of any
mobile platform and is still growing fast. Every day another million users power up their
Android-powered devices for the first time and start looking for apps, games, and other
digital content.
1.1 History
Android, operating system for cellular telephones and tablet computers. Android
began in 2003 as a project of the American technology company Android Inc., to
develop an operating system for digital cameras. In 2004 the project changed to
become an operating system for smart phones. Android Inc., was bought by the
American search engine company Google Inc., in 2005. At Google, the Android team
decided to base their project on Linux, an open source operating system for personal
computers.
On November 5, 2007, Google announced the founding of the Open Handset Alliance, a
consortium of dozens of technology and mobile telephone companies, including Intel
Corporation, Motorola, Inc., NVIDIA Corporation, Texas Instruments Incorporated, LG
Electronics, Inc., Samsung Electronics, Sprint Nextel Corporation, and T-Mobile
(Deutsche Telekom). The consortium was created in order to develop and promote
Android as a free open source operating system with support for third-party
applications. Android-based devices use wireless networks in order to take full
advantage of features such as one-touch Google searches, Google Docs (e.g., word
editors, spreadsheets), and Google Earth (satellite mapping software).
The first cellular telephone to feature the new operating system was the T-Mobile
G1, released on October 22, 2008. In 2012 Android became the most popular operating
system for mobile devices, surpassing apple’s ios, and, as of 2020, about 75 percent of
mobile devices run Android.
1.2 Android Versions
Google provides major incremental upgrades to the Android operating system using confectionery-themed
names. The latest major release is Android 8.0 "Oreo".
Donut
Eclair
Froyo
Gingerbread
Honeycomb
4.0 – 4.0.4 18 October 2011 14–15
Jelly Bean
KitKat
Lollipop
Marshmallow
Nougat
Oreo
1.3 Architecture Of Android
Linux kernel
At the bottom of the layers is Linux - Linux 3.6 with approximately 115 patches. This
provides a level of abstraction between the device hardware and it contains all the
essential hardware drivers like camera, keypad, display etc. Also, the kernel handles all
the things that Linux is really good at such as networking and a vast array of device
drivers, which take the pain out of interfacing to peripheral hardware.
Libraries
On top of Linux kernel there is a set of libraries including open-source Web browser
engine WebKit, well known library libc, SQLite database which is a useful repository for
storage and sharing of application data, libraries to play and record audio and video,
SSL libraries responsible for Internet security etc.
Android Libraries
This category encompasses those Java-based libraries that are specific to Android development.
Examples of libraries in this category include the application framework libraries in addition to
those that facilitate user interface building, graphics drawing and database access. A summary of
some key core Android libraries available to the Android developer is as follows −
• android.app − Provides access to the application model and is the cornerstone of all Android
applications.
• android.database − Used to access data published by content providers and includes SQLite
database management classes.
Android Runtime
This is the third section of the architecture and available on the second layer from the
bottom. This section provides a key component called Dalvik Virtual Machine which is a
kind of Java Virtual Machine specially designed and optimized for Android.
The Dalvik VM makes use of Linux core features like memory management and multi-
threading, which is intrinsic in the Java language. The Dalvik VM enables every Android
application to run in its own process, with its own instance of the Dalvik virtual machine.
The Android runtime also provides a set of core libraries which enable Android
application developers to write Android applications using standard Java programming
language.
Application Framework
• Activity Manager − Controls all aspects of the application lifecycle and activity
stack.
• Content Providers − Allows applications to publish and share data with other
applications.
Applications
You will find all the Android application at the top layer. You will write your application
to be installed on this layer only. Examples of such applications are Contacts Books,
Browser, Games etc.
1.4 Android Studio Installation
Clicking Next took me to the following panel, which provides the option to decline
installing an Android Virtual Device (AVD).
I chose to keep the default settings. After clicking Next, I was taken to
the Configuration Settings panel, where I was asked to choose where to install
Android Studio.
I kept the default installation location and clicked Next, and was greeted with
the Choose Start Menu Folder panel.
I kept the default setting and clicked Install. The following Installing panel appeared:
Clicking Show details causes the names of files being installed and other activities to
be displayed. When installation finished, the Installation Complete panel appeared.
After clicking Next, the installer presented the Completing Android Studio
Setup panel.
To complete the installation, I left the Start Android Studio box checked and
clicked Finish.
I also observed the following Finding Available SDK Components message box.
At this point, Android Studio presented the following Android Studio Setup
Wizard dialog box:
I clicked Next, and the wizard invited me to select an installation type. I kept the default
standard setting.
I clicked Finish and Android Studio began the process of downloading SDK
components.
It can take several minutes for this part of the setup to finish. Clicking Show
Details might relieve some boredom by revealing the various files being downloaded
and unzipped.
This dialog box is used to start up a new Android Studio project, work with an existing
project, and more. It can be accessed by selecting Android Studio from the
Windows Start menu, or the equivalent on another platform.
2.Introduction To Project
In this app, the user will enter the text that he/she wants to convert. The
user will get the translated text on a button click. The user will only be able
to read the translated text.
Activity_main.XML code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@color/black_shade_1"
android:layout_height="match_parent"
style="@style/AppTheme.MaterialTheme"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="81dp"
android:layout_marginTop="20dp"
android:gravity="center"
android:padding="4dp"
android:text="Language Translator"
android:textAlignment="center"
android:textColor="@color/yellow"
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="20dp"
>
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/idFromSpinner"
android:layout_margin="3dp"
android:padding="3dp"
android:gravity="center"
/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:src="@drawable/ic_right_arrow"
app:tint="@color/white" />
<Spinner
android:id="@+id/idToSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_weight="1"
android:gravity="center"
android:padding="3dp"/>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="86dp"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:hint="Source Text"
android:padding="5dp"
android:textColorHint="@color/white"
app:hintTextColor="@color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/idEdtSource"
android:layout_width="match_parent"
android:layout_height="68dp"
android:ems="10"
android:importantForAutofill="no"
android:inputType="textImeMultiLine|textMultiLine"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="OR"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="20sp" />
<ImageView
android:id="@+id/idIVMic"
android:layout_width="70dp"
android:layout_height="64dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/ic_mic"
app:tint="@color/yellow" />
<TextView
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_gravity="center"
android:text="Say Something"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="15sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/idBtnTranslate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:text="Translate"
android:textAllCaps="false" />
<TextView
android:id="@+id/idTVTranslatedTV"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="Translated Text"
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="18sp" />
</LinearLayout>
MainActivity.java
package com.example.languagetranslatorapp;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.google.firebase.ml.common.modeldownload.FirebaseModelDownloadConditions;
import com.google.firebase.ml.naturallanguage.FirebaseNaturalLanguage;
import com.google.firebase.ml.naturallanguage.translate.FirebaseTranslateLanguage;
import com.google.firebase.ml.naturallanguage.translate.FirebaseTranslator;
import com.google.firebase.ml.naturallanguage.translate.FirebaseTranslatorOptions;
import java.util.ArrayList;
import java.util.Locale;
String[] fromLanguages =
{"From","English","Afrikaans","Arabic","Belarusian","Bulgarian","Bengali","Catalan","
Czech","Welsh","Hindi","Urdu","Spanish","Portuguese","Danish","Dutch","French","Germa
n","Italian","Greek","Vietnamese","Japanese","Korean","Chinese","Thai","Russian","Swe
dish","Turkish","Kannada","Marathi"};
String[] toLanguages =
{"To","English","Afrikaans","Arabic","Belarusian","Bulgarian","Bengali","Catalan","Cz
ech","Welsh","Hindi","Urdu","Spanish","Portuguese","Danish","Dutch","French","German"
,"Italian","Greek","Vietnamese","Japanese","Korean","Chinese","Thai","Russian","Swedi
sh","Turkish","Kannada","Marathi"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fromSpinner = findViewById(R.id.idFromSpinner);
toSpinner = findViewById(R.id.idToSpinner);
sourceEdt = findViewById(R.id.idEdtSource);
micIV = findViewById(R.id.idIVMic);
translateBtn = findViewById(R.id.idBtnTranslate);
translatedTV = findViewById(R.id.idTVTranslatedTV);
fromSpinner.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int
position, long id) {
fromLanguageCode = getLanguageCode(fromLanguages[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
fromSpinner.setAdapter(fromAdapter);
toSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int
position, long id) {
tolanguageCode = getLanguageCode(toLanguages[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
translateText(fromLanguageCode,tolanguageCode,sourceEdt.getText().toString());
}
}
});
micIV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE
_FORM);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
i.putExtra(RecognizerIntent.EXTRA_PROMPT,"Speak to convert into
text");
try {
startActivityForResult(i,REQUEST_PERMISSION_CODE);
}catch (Exception e){
e.printStackTrace();
Toast.makeText(MainActivity.this,""+e.getMessage(),Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==REQUEST_PERMISSION_CODE){
if (resultCode==RESULT_OK && data!=null){
ArrayList<String> result =
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
sourceEdt.setText(result.get(0));
}
}
}
private void translateText(int fromLanguageCode, int tolanguageCode, String
source){
translatedTV.setText("Downloading Modal...");
FirebaseTranslatorOptions options = new FirebaseTranslatorOptions.Builder()
.setSourceLanguage(fromLanguageCode)
.setTargetLanguage(tolanguageCode)
.build();
FirebaseTranslator translator =
FirebaseNaturalLanguage.getInstance().getTranslator(options);
FirebaseModelDownloadConditions conditions = new
FirebaseModelDownloadConditions.Builder().build();
translator.downloadModelIfNeeded(conditions).addOnSuccessListener(new
OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
translatedTV.setText("Translating...");
translator.translate(source).addOnSuccessListener(new
OnSuccessListener<String>() {
@Override
public void onSuccess(String s) {
translatedTV.setText(s);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"Fail to
translate:"+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"Fail to download Language
Model"+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
public int getLanguageCode(String language){
int languageCode = 0;
switch (language){
case "English":
languageCode = FirebaseTranslateLanguage.EN;
break;
case "Afrikaans":
languageCode = FirebaseTranslateLanguage.AF;
break;
case "Arabic":
languageCode = FirebaseTranslateLanguage.AR;
break;
case "Belarusian":
languageCode = FirebaseTranslateLanguage.BE;
break;
case "Bulgarian":
languageCode = FirebaseTranslateLanguage.BG;
break;
case "Bengali":
languageCode = FirebaseTranslateLanguage.BN;
break;
case "Catalan":
languageCode = FirebaseTranslateLanguage.CA;
break;
case "Czech":
languageCode = FirebaseTranslateLanguage.CS;
break;
case "Welsh":
languageCode = FirebaseTranslateLanguage.CY;
break;
case "Hindi":
languageCode = FirebaseTranslateLanguage.HI;
break;
case "Urdu":
languageCode = FirebaseTranslateLanguage.UR;
break;
case "Spanish":
languageCode = FirebaseTranslateLanguage.ES;
break;
case "Portuguese":
languageCode = FirebaseTranslateLanguage.PT;
break;
case "Danish":
languageCode = FirebaseTranslateLanguage.DA;
break;
case "Dutch":
languageCode = FirebaseTranslateLanguage.NL;
break;
case "French":
languageCode = FirebaseTranslateLanguage.FR;
break;
case "German":
languageCode = FirebaseTranslateLanguage.DE;
break;
case "Italian":
languageCode = FirebaseTranslateLanguage.IT;
break;
case "Greek":
languageCode = FirebaseTranslateLanguage.EL;
break;
case "Vietnamese":
languageCode = FirebaseTranslateLanguage.VI;
break;
case "Japanese":
languageCode = FirebaseTranslateLanguage.JA;
break;
case "Korean":
languageCode = FirebaseTranslateLanguage.KO;
break;
case "Chinese":
languageCode = FirebaseTranslateLanguage.ZH;
break;
case "Thai":
languageCode = FirebaseTranslateLanguage.TH;
break;
case "Russian":
languageCode = FirebaseTranslateLanguage.RU;
break;
case "Swedish":
languageCode = FirebaseTranslateLanguage.SV;
break;
case "Turkish":
languageCode = FirebaseTranslateLanguage.TR;
break;
case "Kannada":
languageCode = FirebaseTranslateLanguage.KN;
break;
case "Marathi":
languageCode = FirebaseTranslateLanguage.MR;
break;
default:
languageCode = 0;
}
return languageCode;
}
}
4.Implementation
Now run your app and see the output of the app.
5.Testing
6. Results
7. Conclusion And Future Enhancements
Mastering artificial intelligence and deep learning will create a new
generation of translation software. One that delivers more accurate versions
of the original content, in more languages. The future of translation
will cover more cultures, as the internet continues to penetrate in emerging
countries worldwide.
We can also add features such as language orators added to the app that can
spell out the translated text into various dialects of the language.
REFERENCES