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
Fix “A problem occurred starting process 'command node'” in Android Studio for React Native
By
Errong Leng
-
Fix “A problem occurred starting process 'command node'” in Android Studio for React Native If you are building a React Native Android project and encounter this error during Gradle sync: A problem occurred evaluating project ':react-native-svg'. > A problem occurred starting process 'command 'node'' —even though node works perfectly in your terminal—this guide will show you how to fix it quickly. Common Misconceptions This error is often mistaken as a Node.js or PATH issue, but that is not always the case. Node.js is installed and working in your terminal. PATH and environment variables appear correct. Still, Android Studio Gradle sync fails with the above error. The Real Cause The issue typically arises because of an incorrect Gradle JDK configuration inside Android Studio . Gradle runs inside a JVM and uses that JVM to spawn external processes (like node ). If the Gradle JDK is incompatible or misconfigured, Gradle will...
Fix up watchman issue with Ghost
By
三好Daddy
-
# Issue >> >> at BunserBuf.<anonymous> (/home/errong_leng/Ghost/core/client/node_modules/fb-watchman/index.js:95:23) >> at emitOne (events.js:116:13) >> at BunserBuf.emit (events.js:211:7) >> at BunserBuf.process (/home/errong_leng/Ghost/core/client/node_modules/bser/index.js:292:10) >> at /home/errong_leng/Ghost/core/client/node_modules/bser/index.js:247:12 >> at _combinedTickCallback (internal/process/next_tick.js:131:7) >> at process._tickCallback (internal/process/next_tick.js:180:9) >> A non-recoverable condition has triggered. Watchman needs your help! >> The triggering condition was at timestamp=1509698956: inotify-add-watch(/home/errong_leng/Ghost/core/client/node_modules/ember-cli-node-assets/node_modules/broccoli-funn...
Using Mutual TLS (mTLS) in Next.js (Server-Side Only)
By
三好Daddy
-
Using Mutual TLS (mTLS) in Next.js (Server-Side Only) In the previous posts, we covered: Part 1: Making mTLS API requests from Node.js clients Part 2: Enabling mTLS in Node.js servers Now we focus on Next.js applications and how mTLS works depending on deployment. Next.js Cannot Access TLS Handshake Directly Next.js middleware and API routes run after the TLS handshake They cannot see client certificates or verify them Next.js built-in server does not expose Node's HTTPS options like requestCert In short: Next.js middleware cannot enforce mTLS or access TLS handshake details . Any enforcement must happen before the request reaches Next.js. Next.js as an mTLS Client (Server-Side API Calls) Next.js can securely call mTLS-protected APIs from server-side code, such as: API routes Server actions import fs from 'fs'; import https from 'https'; import axios from 'axios'; export async function GET(req) { const...
Comments
Post a Comment