11import { mkdir , readFile , writeFile } from "node:fs/promises" ;
22import path from "node:path" ;
3- import { fileURLToPath } from "node:url" ;
3+ import { fileURLToPath , pathToFileURL } from "node:url" ;
44import { NATIVE_I18N_LOCALES } from "./native-app-i18n.ts" ;
55
66const HERE = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -12,6 +12,17 @@ const APPLE_LOCALE_DIRECTORIES: Record<string, string> = {
1212 "zh-CN" : "zh-Hans" ,
1313 "zh-TW" : "zh-Hant" ,
1414} ;
15+ const LOCALIZED_WRAPPER_CONTRACTS : Record < string , string [ ] > = {
16+ "apps/ios/Sources/Gateway/GatewayQuickSetupSheet.swift" : [
17+ "fullRowToggle(_ title: LocalizedStringKey" ,
18+ ] ,
19+ "apps/ios/WatchApp/Sources/WatchInboxView.swift" : [
20+ "private struct WatchPrimaryLabel: View {\n let title: LocalizedStringKey" ,
21+ "private struct WatchSecondaryLabel: View {\n let title: LocalizedStringKey" ,
22+ "private struct WatchSecondaryButton: View {\n let title: LocalizedStringKey" ,
23+ "private struct WatchDecisionButton: View {\n let title: LocalizedStringKey" ,
24+ ] ,
25+ } ;
1526
1627const CATALOGS = [
1728 {
@@ -100,6 +111,15 @@ function stringsLiteral(value: string): string {
100111
101112export async function checkAppleAppI18n ( ) {
102113 let checked = 0 ;
114+ for ( const [ sourcePath , contracts ] of Object . entries ( LOCALIZED_WRAPPER_CONTRACTS ) ) {
115+ const source = await readFile ( path . join ( ROOT , sourcePath ) , "utf8" ) ;
116+ const missing = contracts . filter ( ( contract ) => ! source . includes ( contract ) ) ;
117+ if ( missing . length ) {
118+ throw new Error (
119+ `Apple i18n wrapper ${ sourcePath } bypasses localized string lookup: ${ missing . join ( ", " ) } ` ,
120+ ) ;
121+ }
122+ }
103123 for ( const spec of CATALOGS ) {
104124 const catalogPath = path . join ( ROOT , spec . path ) ;
105125 const catalog = JSON . parse ( await readFile ( catalogPath , "utf8" ) ) as Catalog ;
@@ -185,7 +205,7 @@ export async function compileMacosLocalizations(outputDir: string) {
185205 }
186206}
187207
188- if ( process . argv [ 1 ] && import . meta. url === `file:// ${ path . resolve ( process . argv [ 1 ] ) } ` ) {
208+ if ( process . argv [ 1 ] && import . meta. url === pathToFileURL ( path . resolve ( process . argv [ 1 ] ) ) . href ) {
189209 const [ command , flag , value ] = process . argv . slice ( 2 ) ;
190210 if ( command === "check" ) {
191211 await checkAppleAppI18n ( ) ;
0 commit comments