The Configurations.swift
file
Open this file in Xcode and keep reading this guide, you'll have to perform some edits in this file in order to get your template ready to run:
App Name
Replace this string with the new name you want to give to this app:
let APP_NAME = "TranslateIt"
AdMob Ads
Replace the string of the variable below with your own
Interstitial Unit ID - you have to create such Unit ID on
apps.admob.com, just follow the instructions on the AdMob's website in case you don't know how to generate a Unit ID:
let ADMOB_INTERSTITIAL_UNIT_ID = "ca-app-pub-3940256099942544/1033173712"
You also have to replace the string into
Info.plist
with your own App ID:
You can get both
App ID and
Unit ID strings from your AdMob Unit page, after creating it:
Sometimes Apple reviewers reject apps because of Ads, the reason why is not clear yet, but a new submission on the App Store will fix the problem and get your app approved - just in case you'll get a rejection because of IDFA issue.
Anyway, after clicking the Submit For Review button on the App Store Connect page of your application, you’ll get something that looks like the picture below. Mark the options shown below and everything should go smoothly on the next review you'll get of your app:
Custom Colors
You can edit the
HEX
values of the following variables as you wish, change the numbers before
#
symbol. The main color of the app and some UI will be affected by your change:
let MAIN_COLOR = hexValue(hex: #E9684F")
PLEASE NOTE that NOT all Views in the app will change accordingly to the new RGB values you've set in the above variable, you will still need to adjust some colors in some Controllers in the Storyboard.
Support email address
Replace the string of the variable below with the one you want to be contacted by users who download your app:
let SUPPORT_EMAIL_ADDRESS = [email protected]"
Google Translate API Key
You must obtain your own Google Translate API Key from the
Google Cloud Platform website, and replace the string of the variable below with your own one:
let GOOGLE_TRANSLATION_API_KEY = "AIzaSyDby9oQjWarxP9EGwA8q7NGD5-94xmAkj"
Follow these steps to generate a Key and enable the Cloud Translate API (you must have an active Google Billing account with your credit card registered in it, and a created Cloud Platform's Project):
-
Log in into your Google account and go here: https://console.cloud.google.com/apis/dashboard
-
Click the ENABLE APIS AND SERVICES button:
-
Type "google traslate" in the search box and select the Cloud Translation API box:
-
Select the Neural Translation Model On line Predictions In Translatio V3 option, then click the MANAGE button:
-
In the Cloud Translation API page - the one with the Overview tab - click the ENABLE API button, then click Credentials from the left menu:
-
Click the Copy button next to the new generated Translation API Key, and use the copied string to replace the
GOOGLE_TRANSLATION_API_KEY
one in Configurations.swift
:
-
Done, you're all set to allow the app to translate text!
List of Supported Languages
The following array is a list of all those languages that the Google Translate API can handle:
let languagesArray = [
"af__Afrikaans",
"sq__Albanian",
"am__Amharic",
"ar__Arabic",
"hy__Armenian",
"az__Azerbaijani",
"eu__Basque",
"be__Belarusian",
"bn__Bengali",
"bs__Bosnian",
"bg__Bulgarian",
"ca__Catalan",
"ceb__Cebuano",
"ny__Chichewa",
"zh__Chinese (Simplified)",
"zh-TW__Chinese (Traditional)",
"co__Corsican",
"hr__Croatian",
"cs__Czech",
"da__Danish",
"nl__Dutch",
"en__English",
"eo__Esperanto",
"et__Estonian",
"tl__Filipino",
"fi__Finnish",
"fr__French",
"fy__Frisian",
"gl__Galician",
"ka__Georgian",
"de__German",
"el__Greek",
"gu__Gujarati",
"ht__Haitian Creole",
"ha__Hausa",
"haw__Hawaiian",
"iw__Hebrew",
"hi__Hindi",
"hmn__Hmong",
"hu__Hungarian",
"is__Icelandic",
"ig__Igbo",
"id__Indonesian",
"ga__Irish",
"it__Italian",
"ja__Japanese",
"jw__Javanese",
"kn__Kannada",
"kk__Kazakh",
"km__Khmer",
"ko__Korean",
"ku__Kurdish (Kurmanji)",
"ky__Kyrgyz",
"lo__Lao",
"la__Latin",
"lv__Latvian",
"lt__Lithuanian",
"lb__Luxembourgish",
"mk__Macedonian",
"mg__Malagasy",
"ms__Malay",
"ml__Malayalam",
"mt__Maltese",
"mi__Maori",
"mr__Marathi",
"mn__Mongolian",
"my__Myanmar (Burmese)",
"ne__Nepali",
"no__Norwegian",
"ps__Pashto",
"fa__Persian",
"pl__Polish",
"pt__Portuguese",
"pa__Punjabi",
"ro__Romanian",
"ru__Russian",
"sm__Samoan",
"gd__Scots Gaelic",
"sr__Serbian",
"st__Sesotho",
"sn__Shona",
"sd__Sindhi",
"si__Sinhala",
"sk__Slovak",
"sl__Slovenian",
"so__Somali",
"es__Spanish",
"su__Sundanese",
"sw__Swahili",
"sv__Swedish",
"tg__Tajik",
"ta__Tamil",
"te__Telugu",
"th__Thai",
"tr__Turkish",
"uk__Ukrainian",
"ur__Urdu",
"uz__Uzbek",
"vi__Vietnamese",
"cy__Welsh",
"xh__Xhosa",
"yi__Yiddish",
"yo__Yoruba",
"zu__Zulu",
]
You may remove some languages from that array, if you want to, but you are NOT allowed to add any custom language code or name. Anyway, I suggest you to just leave that array as it is.
Custom fonts
This App uses
Poppins font, which is already stored into the Xcode Fonts library.
In case you want to add a new font, you have to first drag your
.ttf
or
.otf
font file into the left-side panel in Xcode and click the Finish button in the popup that will show up:
Then select the Label, Button, TextFiled or textView you want to change font to, click the
[T]
icon on the right-side
Attributes inspector panel and select the font you want in the dropdown list:
Utility Functions
Unless you are familiar with iOS programming, you should leave the code of this section as it is since it includes useful functions to show alerts and perform other things in the app.