MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsAppleLocale

Function _cupsAppleLocale

cups/language.c:238–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236 */
237
238const char * /* O - Locale */
239_cupsAppleLocale(CFStringRef languageName, /* I - Apple language ID */
240 char *locale, /* I - Buffer for locale */
241 size_t localesize) /* I - Size of buffer */
242{
243 int i; /* Looping var */
244 CFStringRef localeName; /* Locale as a CF string */
245#ifdef DEBUG
246 char temp[1024]; /* Temporary string */
247
248
249 if (!CFStringGetCString(languageName, temp, (CFIndex)sizeof(temp), kCFStringEncodingASCII))
250 temp[0] = '\0';
251
252 DEBUG_printf(("_cupsAppleLocale(languageName=%p(%s), locale=%p, localsize=%d)", (void *)languageName, temp, (void *)locale, (int)localesize));
253#endif /* DEBUG */
254
255 localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, languageName);
256
257 if (localeName)
258 {
259 /*
260 * Copy the locale name and tweak as needed...
261 */
262
263 if (!CFStringGetCString(localeName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
264 *locale = '\0';
265
266 DEBUG_printf(("_cupsAppleLocale: locale=\"%s\"", locale));
267
268 CFRelease(localeName);
269
270 /*
271 * Map new language identifiers to locales...
272 */
273
274 for (i = 0;
275 i < (int)(sizeof(apple_language_locale) /
276 sizeof(apple_language_locale[0]));
277 i ++)
278 {
279 size_t len = strlen(apple_language_locale[i].language);
280
281 if (!strcmp(locale, apple_language_locale[i].language) ||
282 (!strncmp(locale, apple_language_locale[i].language, len) && (locale[len] == '_' || locale[len] == '-')))
283 {
284 DEBUG_printf(("_cupsAppleLocale: Updating locale to \"%s\".", apple_language_locale[i].locale));
285 strlcpy(locale, apple_language_locale[i].locale, localesize);
286 break;
287 }
288 }
289 }
290 else
291 {
292 /*
293 * Just try the Apple language name...
294 */
295

Callers 1

appleLangDefaultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected