Please carefully read this guide in order to fully configure this template, and remember to test it on a Real Device – the Emulator may fail.
This template has native Apple Swift code, so you can edit it only with Xcode running on a Mac computer. If you don’t have it, download it for free on the Mac App Store.
Info.plist
file – you can find it in the files list on the left-side panel – and set the text you wish in the Value
column of the Privacy rows.Main.storyboard
and you can find it in the list of file that is shown in left-side panel of the Xcode window.Assets.xcassets
folder.
let APP_NAME = "Magic 8 Ball"
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:#
symbol. The main color of the app and some UI will be affected by your change:
let MAIN_COLOR = hexValue(hex: "#0e0e0e")
.ttf
or .otf
font file into the left-side panel in Xcode and click the Finish button in the popup that will show up: let APP_STORE_LINK = "http://itunes.apple.com/app/idXXXXXXXXX"
You can grab the App ID of your app in the App Information section in the App Store Connect page of your app.
bkg
. let BACKGROUNDS_NUMBER = 8
If you want to add one more background image, follow these simple steps: let languagesArray = [
"en__English",
"fr__French",
"de__German",
"it__Italian",
"es__Spanish",
]
If you scroll down, you can also see other arrays – like answers_en, alternative_answers_en, funny_answers_en, etc. let languagesArray = [
•••
"es__Spanish",
"fi__Finnish", // <-- NEW LANGUAGE ADDED
]
- As you can see by the example above, you type the 2-digit language code (fi), followed by 2 underscores (__), followed by the language name (Finnish). This syntax is important, you must follow it while adding languages in order for the app to work properly.
// ------------------------------------------------
// MARK: - GLOBAL VARIABLES
// ------------------------------------------------
- Rename those arrays by replacing en with fi, like this: answers_fi, alternative_answers_fi and funny_answers_fi
- Translate all their string items into Finnish
- After that, copy the whole translations_en
array and paste it right above the GLOBAL VARIABLES comment – like you did for the other arrays
- Rename that array by replacing en into fi, like this: translations_fi
- Translate all its items into Finnish
- When you’re done, enter the Home.swift file and scroll down to the bottom, until you find the setTranslations() function
- Copy the whole "en" case:
// English
case "en":
if selectedResponses == 0 { localAnswersArr = answers_en
} else if selectedResponses == 1 { localAnswersArr = alternative_answers_en
} else if selectedResponses == 2 { localAnswersArr = funny_answers_en }
answerLabel.text = translations_en[0]
infoLabel.text = translations_en[2]
changeLanguageMess = translations_en[3]
cancelStr = translations_en[4]
selectOptionStr = translations_en[5]
achievementsStr = translations_en[6]
changeBkgStr = translations_en[7]
removeBkgStr = translations_en[8]
shareStr = translations_en[14]
sharingMessage = translations_en[15]
break
- Paste those lines of code right above this line, inside the switch statement:
default: break
- Now replace all en into fi, make that code look like this:
// Finnish
case "fi":
if selectedResponses == 0 { localAnswersArr = answers_fi
} else if selectedResponses == 1 { localAnswersArr = alternative_answers_fi
} else if selectedResponses == 2 { localAnswersArr = funny_answers_fi }
answerLabel.text = translations_fi[0]
infoLabel.text = translations_fi[2]
changeLanguageMess = translations_fi[3]
cancelStr = translations_fi[4]
selectOptionStr = translations_fi[5]
achievementsStr = translations_fi[6]
changeBkgStr = translations_fi[7]
removeBkgStr = translations_fi[8]
shareStr = translations_fi[14]
sharingMessage = translations_fi[15]
break
- Enter the Responses.swift file, scroll down to the setTranslations() function and copy the whole "en" case:
// English
case "en":
titleLabel.text = translations_en[6]
responsesArray.append(translations_en[11])
responsesArray.append(translations_en[12])
responsesArray.append(translations_en[13])
break
- Paste those lines of code right above the default:break line – in the switch statement // Finnish
case "fi":
titleLabel.text = translations_fi[6]
responsesArray.append(translations_fi[11])
responsesArray.append(translations_fi[12])
responsesArray.append(translations_fi[13])
break
- You’re finally done. Run the app and check it out, if you’ve done everything correctly, you’ll be bale to select the Finnish language and get all data into such language. // MARK: - TABLES & COLUMNS NAMES
fireInterstitialAd;
Xcode will show you a list of Swift files where such code is located.