iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 16
0
Software Development

30 天上手 iOS App 開發系列 第 28

30 天上手 iOS App 開發 Day 30

延續iOS App 開發 Day 29之內容

展開左側的 Localizable.strings,這時會看到有兩個多國語系檔案(英文、繁體中文)
https://ithelp.ithome.com.tw/upload/images/20180118/20107506vaAXsNkJUB.png
在英文、繁體中文的多國語文件下新增程式碼
新增程式碼遵照 key、value 之型式,前面為Key後面為Value
在繁體中文之檔案這邊宣告"Text" = "中文";而英文之檔案這邊宣告"Text" = "English";
切記一定要使用分號做檔案之區隔
https://ithelp.ithome.com.tw/upload/images/20180118/20107506h1D9k2zXxf.png
https://ithelp.ithome.com.tw/upload/images/20180118/20107506SsCYdNXV1Q.png
接著我們先在StoryBoard新增一個Label,連接ViewController
https://ithelp.ithome.com.tw/upload/images/20180118/20107506A9kxSWs1iN.png
https://ithelp.ithome.com.tw/upload/images/20180118/20107506laWeQV0QOs.png
宣告label的文字為多國語系內容,宣告使用之key值,和指定對應之檔案位置名稱,完成後執行程式
https://ithelp.ithome.com.tw/upload/images/20180118/20107506t2q02O5mdP.png
先看預設設定英文語系之內容
https://ithelp.ithome.com.tw/upload/images/20180118/2010750618k9QS3xDX.png
接著叫大家如何切換語系
點選設定 -> 語言 -> 繁體中文
https://ithelp.ithome.com.tw/upload/images/20180118/201075060c24TWovlI.png
https://ithelp.ithome.com.tw/upload/images/20180118/20107506cjEZENy5ZZ.png
https://ithelp.ithome.com.tw/upload/images/20180118/20107506nQq8Hlwu13.png
https://ithelp.ithome.com.tw/upload/images/20180118/20107506EPMkGbaGln.png
設定完成後執行在執行一次App會發現內容已經轉換為繁體中文了
https://ithelp.ithome.com.tw/upload/images/20180118/20107506jfRlxMrwT8.png


上一篇
30 天上手 iOS App 開發 Day 29
系列文
30 天上手 iOS App 開發28
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言