LANGUAGE TRANSLATOR APP Report

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JNANA SANGAMA, BELAGAVI – 590 018

A Mini Project Report on

“LANGUAGE TRANSLATOR APP”


Submitted in partial fulfillment of the requirements as a part of the

Mobile Application Development Laboratory with


Mini Project (18CSMP68)
For the award of degree of

Bachelor of Engineering
in
Information Science and Engineering
Submitted by
RAYAN BHATTACHARJEE SALONI KUMARI SHIVAM PALIWAL

1RN18IS085 1RN18IS090 1RN18IS099

Mini Project Coordinators


Ms. Sowmya S K Mrs. Chandan Rani S R
Assistant Professor Assistant Professor
Dept. of ISE, RNSIT Dept. of ISE, RNSIT

Department of Information Science and Engineering


RNS Institute of Technology
Channasandra, Dr. Vishnuvardhan Road, RR Nagar Post,
Bengaluru – 560 098
2020 -2021
RNS Institute of Technology
Channasandra, Dr.Vishnuvardhan Road, RR Nagar Post,
Bengaluru – 560 098
DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING

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.

___________________ _____________________ ______________________


Mrs. Chandan Rani S R Ms. Sowmya S K Dr. Suresh L
Coordinator Coordinator Professor and HOD
Assistant Professor Assistant Professor

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 profoundly thank Management of RNS Institute of Technology for


providing such a healthy environment to carry out this Mobile Application Development
Laboratory with Mini Project Work.

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.

RAYAN BHATTACHARJEE SALONI KUMARI SHIVAM PALIWAL


USN: 1RNXXIS085 USN: 1RNXXIS090 USN: 1RNXXIS099
ii

Table of Contents
Certificate
Abstract i

Acknowledgment ii

Table Of Contents iii

List Of Figures vi

List Of Tables viii

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

Follow the report specifications


• For chapter heading size 16,
• Sub heading size 14 ,
• Text size 12
• 1.5 line spacing,
• Justification of contents,
• Proper header and footers,
• Name the figures and tables appropriately and refer them in text also.
1.INTRODUCTION TO ANDROID

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".

Code name Version number Initial release date API level

N/A 1.0 23 September 2008 1

N/A 1.1 9 February 2009


2

Cupcake 1.5 27 April 2009 3

1.6 15 September 2009 4

Donut

2.0 – 2.1 26 October 2009 5–7

Eclair

2.2 – 2.2.3 20 May 2010 8

Froyo

2.3 – 2.3.7 6 December 2010 9–10

Gingerbread

3.0 – 3.2.6 22 February 2011 11–13

Honeycomb
4.0 – 4.0.4 18 October 2011 14–15

Ice Cream Sandwich

4.1 – 4.3.1 9 July 2012 16–18

Jelly Bean

4.4 – 4.4.4 31 October 2013 19–20

KitKat

5.0 – 5.1.1 12 November 2014 21–22

Lollipop

6.0 – 6.0.1 5 October 2015 23

Marshmallow

7.0 22 August 2016 24

Nougat

8.0 August 21, 2017 26

Oreo
1.3 Architecture Of Android

Android operating system is a stack of software components which is roughly


divided into five sections and four main layers as shown below in the
architecture diagram.

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.content − Facilitates content access, publishing and messaging between applications


and application components.

• android.database − Used to access data published by content providers and includes SQLite
database management classes.

• android.opengl − A Java interface to the OpenGL ES 3D graphics rendering API.

• android.os − Provides applications with access to standard operating system services


including messages, system services and inter-process communication.
• android.text − Used to render and manipulate text on a device display.

• android.view − The fundamental building blocks of application user interfaces.

• android.widget − A rich collection of pre-built user interface components such as buttons,


labels, list views, layout managers, radio buttons etc.

• android.webkit − A set of classes intended to allow web-browsing capabilities to be built into


applications.
Having covered the Java-based core libraries in the Android runtime, it is now time to turn our
attention to the C/C++ based libraries contained in this layer of the Android software stack .

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

The Application Framework layer provides many higher-level services to applications in


the form of Java classes. Application developers are allowed to make use of these
services in their applications.
The Android framework includes the following key services −

• Activity Manager − Controls all aspects of the application lifecycle and activity
stack.

• Content Providers − Allows applications to publish and share data with other
applications.

• Resource Manager − Provides access to non-code embedded resources such as


strings, color settings and user interface layouts.

• Notifications Manager − Allows applications to display alerts and notifications to


the user.

• View System − An extensible set of views used to create application user


interfaces.

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

I launched android-studio-ide-181.5056338-windows.exe to start the installation


process. The installer responded by presenting the Android Studio Setup dialog box.

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.

Running Android Studio


The first time Android Studio runs, it presents a Complete Installation dialog box that
offers the option of importing settings from a previous installation.
I chose not to import settings (the default selection) and clicked OK, and was rewarded
with the following splash screen:

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 was then given the opportunity to choose a user interface theme.


I kept the default IntelliJ setting and clicked Next. Android Studio next provided the
opportunity to verify settings.

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.

For my AMD-based computer, an unpleasant surprise awaited after the components


had completely downloaded and unzipped:
My options are to either put up with the slow emulator or use an Android device to
speed up development. In Part 3 I'll show you how I resolved this issue.
Finally, I clicked Finish to complete the wizard. The Welcome to Android
Studio dialog box appeared.

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

Today we will make a language translator. Language translators are very


important, especially for people who travel abroad. This app allows users to
speak any language the user wants without even knowing that language.

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.

2.1 Overview Of The Project


We will be building a simple application in which we will be showing an EditText field
and we will add any input to that Text-field. Along with that, we will be displaying
a Button to translate that text to the any language. After clicking that button our text
will be translated to the selected language which we can get to see in the text view.

2.2 Aim Of The Project


Translators convert written materials from one language into another language.
The goal of a translator is to have people read the translation as if it were the original written
material.
3. System Design

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;

public class MainActivity extends AppCompatActivity {

private Spinner fromSpinner,toSpinner;


private TextInputEditText sourceEdt;
private ImageView micIV;
private MaterialButton translateBtn;
private TextView translatedTV;

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"};

private static final int REQUEST_PERMISSION_CODE = 1;


int languageCode,fromLanguageCode,tolanguageCode = 0;

@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) {

}
});

ArrayAdapter fromAdapter = new


ArrayAdapter(this,R.layout.spinner_item,fromLanguages);

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) {

}
});

ArrayAdapter toAdapter = new


ArrayAdapter(this,R.layout.spinner_item,toLanguages);
toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
toSpinner.setAdapter(toAdapter);
translateBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
translatedTV.setText("");
if(sourceEdt.getText().toString().isEmpty()){
Toast.makeText(MainActivity.this,"Please enter your text to
translate", Toast.LENGTH_SHORT).show();
}else if (fromLanguageCode==0){
Toast.makeText(MainActivity.this,"Please select source
language",Toast.LENGTH_LONG).show();
}else if (tolanguageCode==0){
Toast.makeText(MainActivity.this,"Please select the language to
make translation",Toast.LENGTH_SHORT).show();
}else{

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

Step 1: Create a New Project

Step 2: Connect your app to Firebase


After creating a new project in Android Studio connect your app to Firebase.
For connecting your app to Firebase. Navigate to Tools on the top bar. After
that click on Firebase. A new window will open on the right side. Inside that
window click on Firebase ML and then click on Use Firebase ML kit in Android.
After clicking on this option you will get to see the below screen. On this
screen click on Connect to Firebase option to connect your app to Firebase.
Click on Connect option to connect your app to Firebase and add the below
dependency to your build.gradle file.

Step 3: Adding dependency for language translation to build.gradle file


Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below
dependency in the dependencies section.

Step 4: Adding permissions to access the Internet in your Android App


Navigate to the app > AndroidManifest.xml file and add the below code to it.
Comments are added in the code to get to know in more detail.

Step 5: Working with the activity_main.xml file


Navigate to the app > res > layout > activity_main.xml and add the below
code to that file. Below is the code for the activity_main.xml file.

Step 6: Working with the MainActivity.java file

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

You might also like