Skip to content

Commit d3090e2

Browse files
committed
NSBundle: fix es.lproj path not generated
The conversion between BCP 47 language tags and the old-style language names ('English', 'German', etc) is quite complex, mapping ISO 639-1 language tags to the old-style names, and the result back to ISO 639-1 (-ish). The ISO 639-1 tag for spanish 'es' maps to 'Spanish', which in turn maps back to 'sp'. The original input is not added to the list of possible names for 'lproj' folders. We fix this by operating on the official input, when splitting language, variant, and region. The "mapped" tag is always added just to keep 'sp.lproj' working.
1 parent 9c6bd9e commit d3090e2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Source/NSBundle.m

+13-7
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,32 @@
124124
}
125125
}
126126

127-
if ((r = [canon rangeOfString: @"-"]).length > 1)
127+
if ((r = [full rangeOfString: @"-"]).length > 1)
128128
{
129-
dialect = [canon substringFromIndex: NSMaxRange(r)];
130-
lang = [canon substringToIndex: r.location];
129+
dialect = [full substringFromIndex: NSMaxRange(r)];
130+
lang = [full substringToIndex: r.location];
131131
if ((r = [dialect rangeOfString: @"_"]).length > 1)
132132
{
133133
region = [dialect substringFromIndex: NSMaxRange(r)];
134134
dialect = [dialect substringToIndex: r.location];
135135
}
136136
}
137-
else if ((r = [canon rangeOfString: @"_"]).length > 1)
137+
else if ((r = [full rangeOfString: @"_"]).length > 1)
138138
{
139-
region = [canon substringFromIndex: NSMaxRange(r)];
140-
lang = [canon substringToIndex: r.location];
139+
region = [full substringFromIndex: NSMaxRange(r)];
140+
lang = [full substringToIndex: r.location];
141141
}
142142
else
143143
{
144-
lang = canon;
144+
lang = full;
145145
}
146146

147147
a = [NSMutableArray arrayWithCapacity: 5];
148+
/* We now that the canonical language does not have a variant or region
149+
* extension
150+
*/
151+
[a addObject: canon];
152+
148153
if (nil != dialect && nil != region)
149154
{
150155
[a addObject: [NSString stringWithFormat: @"%@-%@_%@",
@@ -165,6 +170,7 @@
165170
{
166171
[a addObject: alias];
167172
}
173+
NSLog(@"Alt ALngs: %@ canon=%@ alias=%@", a, canon, alias);
168174
}
169175
return a;
170176
}

0 commit comments

Comments
 (0)