I’m excited to share a set of mobile apps I’ve recently completed and published on both the Google Play Store and the Apple App Store. These apps are designed with a simple goal in mind: to make meaningful, structured content more accessible, whether you’re studying theology or improving your English vocabulary. 📱 Now Available on Both Platforms All apps are live and available for download: Google Play Developer Page: https://play.google.com/store/apps/dev?id=5835943159853189043 Apple App Store Developer Page: https://apps.apple.com/ca/developer/q-z-l-corp/id1888794100 📖 Theology & Confession Study Apps For those interested in Reformed theology and classical Christian teachings, I’ve developed a series of apps that present foundational texts in a clean, focused reading format: The Belgic Confession Canons of Dort Heidelberg Catechism Westminster Shorter Catechism Each app is designed to provide a distraction-free experience, making it easier to read, reflect, and revisit these im...
我们如何为 macOS 应用添加国际化和多语言支持
- Get link
- X
- Other Apps
By
Errong Leng
-
我们如何为 macOS 应用添加国际化和多语言支持
支持多语言对于拓展全球用户至关重要。本文将以我们的 macOS 应用 iTrans 为例,介绍我们如何通过 Swift 和 Xcode 实现国际化(i18n)和中文本地化。
1. 审查所有用户可见文本
第一步是查找代码中所有用户可见的字符串。我们在 SwiftUI 视图、模型和操作符中搜索所有硬编码文本。
2. 提取待本地化字符串
我们将所有硬编码字符串替换为支持本地化的 API:
- 在 SwiftUI 中,
Text视图使用LocalizedStringKey。 - 其他字符串使用
NSLocalizedString。
Text(LocalizedStringKey("Unlock your iPhone"))
// 或
NSLocalizedString("Untitled", comment: "File with no name")
3. 创建本地化文件
我们为每种支持的语言创建了 Localizable.strings 文件:
en.lproj/Localizable.strings—— 英文zh-Hans.lproj/Localizable.strings—— 简体中文
英文示例:
"Unlock your iPhone" = "Unlock your iPhone";
中文示例:
"Unlock your iPhone" = "解锁你的 iPhone";
4. 将本地化文件添加到 Xcode 工程
为了让 Xcode 识别本地化文件:
- 我们通过项目导航器将
Localizable.strings文件添加到工程。 - 在文件检查器中,启用本地化并勾选所有支持的语言。
5. 测试本地化效果
Xcode 让我们可以轻松测试不同语言下的应用效果:
- 在 Scheme 编辑器中,将应用语言设置为“简体中文”并运行应用。
- 我们还验证了所有界面文本在英文和中文下都能正确显示。
6. 效果展示
通过以上步骤,我们的应用现已完整支持英文和中文。所有用户可见文本都已本地化,用户切换语言体验流畅。
结论:
在 Swift 和 Xcode 中实现国际化非常直接。只需遵循最佳实践:提取所有用户可见文本、使用本地化 API、为每种语言维护 .strings 文件并充分测试。这样你的应用就能面向全球用户。
❤️ Support This Blog
If this post helped you, you can support my writing with a small donation. Thank you for reading.
Popular Posts
A New Collection of Thoughtful Learning Apps — Now Available on iOS & Android
By
Errong Leng
-
I’m excited to share a set of mobile apps I’ve recently completed and published on both the Google Play Store and the Apple App Store. These apps are designed with a simple goal in mind: to make meaningful, structured content more accessible, whether you’re studying theology or improving your English vocabulary. 📱 Now Available on Both Platforms All apps are live and available for download: Google Play Developer Page: https://play.google.com/store/apps/dev?id=5835943159853189043 Apple App Store Developer Page: https://apps.apple.com/ca/developer/q-z-l-corp/id1888794100 📖 Theology & Confession Study Apps For those interested in Reformed theology and classical Christian teachings, I’ve developed a series of apps that present foundational texts in a clean, focused reading format: The Belgic Confession Canons of Dort Heidelberg Catechism Westminster Shorter Catechism Each app is designed to provide a distraction-free experience, making it easier to read, reflect, and revisit these im...
2023, New Start! New AdSense Account! New Earnings!
By
Errong Leng
-
It's been a while after I created adsense account to display ads on this blog. A few years later the payment finally reached my payout threshold, I just found the existed adsense account is bind to China. but I moved to Canada 3 years ago. I tried to change the country of it, but just found Unfortunately it's not possible to change the country of your payment address in AdSense. If you've moved to a new country or territory, you'll need to cancel your existing AdSense account and create a new AdSense account . So I created a new adsense account today on 2023-01-12. Though new account is still under reviewing, I believe it will be approved soon. To reach out payout threshold in this year, I set up the below plan: write one blog per week day!!! write one blog per week day!!! write one blog per week day!!! Try ingress more traffic to this blog
react-native run-android : do not build/update modified code(App.js)
By
三好Daddy
-
Solution react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res c:\Users\lenger\Desktop\webrowser>react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res Scanning folders for symlinks in c:\Users\lenger\Desktop\webrowser\node_modules (43ms) Scanning folders for symlinks in c:\Users\lenger\Desktop\webrowser\node_modules (38ms) Loading dependency graph, done. bundle: start bundle: finish bundle: Writing bundle output to: android/app/src/main/assets/index.android.bundle bundle: Done writing bundle output Run react-native run-android again, you will find your modification work.
Comments
Post a Comment