Skip to content

fix(apple): return the current locale as a bcp 47 code without keywords - #334

Merged
grabbou merged 2 commits into
feat/apple-embeddings-model-infofrom
fix/apple-current-locale
Oct 26, 2026
Merged

grabbou merged 2 commits into
feat/apple-embeddings-model-infofrom
fix/apple-current-locale

Conversation

@grabbou

@grabbou grabbou commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #333.

AppleUtils.getCurrentLocale() returned NSLocale.currentLocale.localeIdentifier. When the device's language and region differ, that identifier carries keywords such as en_US@rg=plzzzz. It's the default language of the speech, transcription and embedding models, and AVSpeechSynthesisVoice(language:) expects a code like en-US.

It now returns a BCP 47 code built from the locale's language, script and region, without keywords: en-US, or zh-Hans-CN.

An earlier attempt (00786b6c, reverted in d4fdc92c on the reasoning-level branch) only targeted transcription, which turned out not to need it, since SpeechTranscriber resolves such locales itself. Speech synthesis and the getCurrentLocale() contract still did.

The existing reads the current locale harness test failed on main on simulators whose locale has a region override (en_US@rg=plzzzz here) and passes now. Availability and speech tests pass on the iPhone 18 Pro simulator (iOS 27).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Locale codes now include the language and any available script and country codes, without extra locale-specific keywords.

When language and region differ, the locale identifier carries keywords
such as en_US@rg=plzzzz. It is the default language of the speech,
transcription and embedding models, and AVSpeechSynthesisVoice does not
accept it, so getCurrentLocale() now returns en-US.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai Ready Ready Preview Oct 26, 2026 2:52pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 006bac41-5436-4047-9fce-15ef23fe4b33
Commits

Reviewing files that changed from the base of the PR and between 663cfcf and 0cc9e4e.

Files selected for processing: 1
  • packages/apple-llm/ios/utils/AppleUtils.mm

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

getCurrentLocale now returns a hyphen-joined locale code built from the current locale’s language code and, when present, its script and country codes.

Changes: Locale Formatting

Layer / File(s) Summary
Build locale code
packages/apple-llm/ios/utils/AppleUtils.mm
getCurrentLocale joins the language code with available script and country codes instead of returning localeIdentifier.

Priority: Not assessed

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Possibly related PRs

  • callstackincubator/ai#316: This PR selects a language for Apple speech synthesis and can use getCurrentLocale as its default language source.
Merge Risk: Minimal · up to 1168b

No current merge-blocking risk was established for this locale-formatting change.

Architecture risk: Low · up to 1168b

The change affects 1 system.

Changed systems: packages/apple-llm

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/apple-llm (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/apple-llm/ios/utils/AppleUtils.mm: getCurrentLocale replaces localeIdentifier with a hyphen-joined code containing the language, followed by the script and country when present.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: returning an Apple locale as a BCP 47 code without locale keywords.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@grabbou
grabbou added this pull request to stack #335 October 26, 2026 14:55
@grabbou
grabbou merged commit 4d067ca into main Oct 26, 2026
8 of 9 checks passed
@grabbou
grabbou deleted the fix/apple-current-locale branch October 26, 2026 14:56

This branch was successfully deployed

1 active deployment
Preview — 1168b14e Deployed Oct 26, 2026 by vercel[bot]
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