Skip to content

Adding localization feature and supporting Chinese Simplified - #111

Open
henry-ji wants to merge 3 commits into
momenbasel:mainfrom
henry-ji:translate
Open

henry-ji wants to merge 3 commits into
momenbasel:mainfrom
henry-ji:translate

Conversation

@henry-ji

@henry-ji henry-ji commented Nov 5, 2026 •

Copy link
Copy Markdown

Pesty is literally an awesome software and I really enjoy it a lot. As a Chinese user, I'm glad to add Chinese Simplified to this software and it's my honor to promote this amazing project to more users in China. I'm also happy to help translate the README into Chinese after the pull request is approved. This PR also adds support for easy adding further translations and the detailed steps will be listed below.

About the PR

What is modified

Nothing except that all the texts written in the script are changed to dynamic ones to supprort multi-language feature, which includes:

  • .localized are added after plain texts. For example: "This is a line of text" -> "This is a line of text".localized
  • texts with formatted parameter are put into L() functions. For example "Paste to \(name)" is changed into L("Paste to %@", name)

What is deleted

Literally nothing

What is added

  • /Sources/Locaization

    • AppLanguage.swift

      This script records all the supported languages, which now only include English and Chinese Simplified.

    • LocalizationManager.swift

      This script is responsible for loading translations and provides the function of .localized and L(). The function when language is changed in the settings are also handled by this script.

  • /Sources/Resources

    • xx.lproj 's

      These are folders for different languages and the name of the folders should be the same with the language name defined in /Sources/Locaization/AppLaguage/swift.

      The Localizable file contains each string used in the software and records its translation.

  • /Settings/SettingsView.swift and /Settings/Settings.swift

    Some codes are added to deal with the actions of language change and a selection is added on the top of general settings for the user to select language.

How to add more languages

  1. Add a new case to /Sources/Locaization/AppLanguage.swift
  2. Add the corresponding display name and local code in the same file under var displayName: and var localeCode:
  3. Duplicate /Resources/en.lproj and change the file name to the new language
  4. Modify the Localizable file under the folder

brokiliss pushed a commit to brokiliss/pesty that referenced this pull request Nov 8, 2026
Squash-merged from henry-ji/pesty branch `translate` (PR momenbasel#111), built on
46031a5. Every user-facing string goes through a runtime lookup, English
and Chinese tables hold the same 216 keys, and Settings gains a language
picker that switches without relaunching.

Co-authored-by: henry-ji <93390386+henry-ji@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant