| 75 | */ |
| 76 | |
| 77 | void |
| 78 | cgiCopyTemplateLang(const char *tmpl) /* I - Base filename */ |
| 79 | { |
| 80 | char filename[1024], /* Filename */ |
| 81 | locale[16], /* Locale name */ |
| 82 | *locptr; /* Pointer into locale name */ |
| 83 | const char *directory, /* Directory for templates */ |
| 84 | *lang; /* Language */ |
| 85 | FILE *in; /* Input file */ |
| 86 | |
| 87 | |
| 88 | fprintf(stderr, "DEBUG2: cgiCopyTemplateLang(tmpl=\"%s\")\n", |
| 89 | tmpl ? tmpl : "(null)"); |
| 90 | |
| 91 | /* |
| 92 | * Convert the language to a locale name... |
| 93 | */ |
| 94 | |
| 95 | if ((lang = getenv("LANG")) != NULL) |
| 96 | { |
| 97 | locale[0] = '/'; |
| 98 | strlcpy(locale + 1, lang, sizeof(locale) - 1); |
| 99 | |
| 100 | if ((locptr = strchr(locale, '.')) != NULL) |
| 101 | *locptr = '\0'; /* Strip charset */ |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | locale[0] = '\0'; |
| 106 | } |
| 107 | |
| 108 | fprintf(stderr, "DEBUG2: lang=\"%s\", locale=\"%s\"...\n", |
| 109 | lang ? lang : "(null)", locale); |
| 110 | |
| 111 | /* |
| 112 | * See if we have a template file for this language... |
| 113 | */ |
| 114 | |
| 115 | directory = cgiGetTemplateDir(); |
| 116 | |
| 117 | snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl); |
| 118 | if ((in = fopen(filename, "r")) == NULL) |
| 119 | { |
| 120 | locale[3] = '\0'; |
| 121 | |
| 122 | snprintf(filename, sizeof(filename), "%s%s/%s", directory, locale, tmpl); |
| 123 | if ((in = fopen(filename, "r")) == NULL) |
| 124 | { |
| 125 | snprintf(filename, sizeof(filename), "%s/%s", directory, tmpl); |
| 126 | in = fopen(filename, "r"); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | fprintf(stderr, "DEBUG2: Template file is \"%s\"...\n", filename); |
| 131 | |
| 132 | /* |
| 133 | * Open the template file... |
| 134 | */ |
no test coverage detected