Hi all,
Asking for help here and any suggestions and edit welcomed!
We are doing a project,trying to localized this open source iOS app here: Tic-Tac-Toe
Here are the questions/challenges we encounter:
-------------Using Xcode to build the project---------------
-
We are trying to find the localizable strings inside the file. Is there any quick way to find all the translatable text all at once? I managed to find the text in "GameScene.swift":
-
Followed the instruction in these two posts:
ios-localization-tutorial
iphone_app_localization
created the Localizable.strings files for the base and another locale (in my case, I used zh-Hans) -
What I put inside each Localiable.strings file:
"Newborn" = "Newborn";
"Toddler" = "Toddler";
"Dummy" = "Dummy";
"Pupil" = "Pupil";
"Student" = "Student";
"B.S." = "B.S.";
"M.S." = "M.S.";
"PhD" = "PhD";
"Nikola Tesla" = "Nikola Tesla";
"UFO" = "UFO";
This is what I added for the base strings file.
"Newborn" = "新生儿";
"Toddler" = "幼儿";
"Dummy" = "小孩";
"Pupil" = "小学生";
"Student" = "中学生";
"B.S." = "大学生";
"M.S." = "硕士生";
"PhD" = "博士生";
"Nikola Tesla" = "尼古拉·特斯拉";
"UFO" = "外星人";
This is for zh-Hans strings file.
-
Editing the source code where the translatable text occurs:
The former source code is like this:enum DifficultyLevel: String { case one = "Newborn" case two = "Toddler" case three = "Dummy" case four = "Pupil" case five = "Student" case six = "B.S." case seven = "M.S." case eight = "PhD" case nine = "Nikola Tesla" case ufo = "UFO"}
Since it's not just simple text, instead, its inside an enum function, I did some google search in order to make it work.
---I changed it to the following based on some StackOverflow posts---
enum DifficultyLevel: String {
case one = "Newborn"
case two = "Toddler"
case three = "Dummy"
case four = "Pupil"
case five = "Student"
case six = "B.S."
case seven = "M.S."
case eight = "PhD"
case nine = "Nikola Tesla"
case ufo = "UFO"
func localizedString() -> String {
return NSLocalizedString( self.rawValue, comment: "")
}
static func getLevelFor(levelChoice:DifficultyLevel) -> String {
return levelChoice.localizedString()
}
}
However, after doing this, and change the phone's language (in simulator), it still didn't show up....
Any help? Thanks a lot !!!