Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build

on:
push:
branches: [ "main", "claude/**" ]
paths:
- ".github/workflows/build.yml"
- "Ice/**/*.swift"
- "Ice.xcodeproj/**"
pull_request:
paths:
- "Ice/**/*.swift"
- "Ice.xcodeproj/**"

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- name: Build
run: |
xcodebuild -project Ice.xcodeproj -scheme Ice \
-derivedDataPath DerivedData \
-configuration Release \
build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
- name: Ad-hoc sign
run: |
BUILT_DIR=$(xcodebuild -project Ice.xcodeproj -scheme Ice \
-configuration Release -derivedDataPath DerivedData \
-showBuildSettings 2>/dev/null | grep " BUILT_PRODUCTS_DIR" | awk '{print $NF}')
APP_PATH="$BUILT_DIR/Ice.app"
echo "Signing: $APP_PATH"
codesign --force --deep --sign - "$APP_PATH"
codesign -dv "$APP_PATH" 2>&1 | head -5
- name: Package .app
run: |
BUILT_DIR=$(xcodebuild -project Ice.xcodeproj -scheme Ice \
-configuration Release -derivedDataPath DerivedData \
-showBuildSettings 2>/dev/null | grep " BUILT_PRODUCTS_DIR" | awk '{print $NF}')
APP_PATH="$BUILT_DIR/Ice.app"
echo "BUILT_PRODUCTS_DIR=$BUILT_DIR"
echo "APP_PATH=$APP_PATH"
ls -ld "$APP_PATH"
ditto -c -k --keepParent "$APP_PATH" Ice-app.zip
ls -lh Ice-app.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Ice-app
path: Ice-app.zip
41 changes: 41 additions & 0 deletions Ice/Localization/AppLanguage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// AppLanguage.swift
// Ice
//

import Foundation

/// The language to show in the interface.
enum AppLanguage: String, CaseIterable, Codable {
case system
case english
case chinese

/// The resolved language based on the current setting.
var resolvedLanguage: Locale.LanguageCode {
switch self {
case .english:
return .english
case .chinese:
return .chinese
case .system:
let preferred = Locale.preferredLanguages.first ?? "en"
if preferred.hasPrefix("zh") {
return .chinese
}
return .english
}
}
}

extension AppLanguage: Identifiable {
var id: String { rawValue }

var localizationKey: LocalizationKey {
switch self {
case .system: .systemLanguage
case .english: .english
case .chinese: .chinese
}
}
}
Loading