36 lines
640 B
C
36 lines
640 B
C
/**
|
|
* Copyright (c) 2024 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "language.h"
|
|
#include "assert/assert.h"
|
|
|
|
language_t LANGUAGE;
|
|
|
|
void languageInit() {
|
|
memset(&LANGUAGE, 0, sizeof(language_t));
|
|
}
|
|
|
|
int32_t languageGet(
|
|
char_t *buffer,
|
|
const char_t *key,
|
|
...
|
|
) {
|
|
assertNotNull(key, "Key cannot be NULL.");
|
|
|
|
int32_t i;
|
|
while(i < LANGUAGE.count) {
|
|
if(strcmp(key, LANGUAGE.keys[i]) != 0) {
|
|
i++;
|
|
continue;
|
|
}
|
|
|
|
if(buffer != NULL) strcpy(buffer, LANGUAGE.strings[i]);
|
|
return strlen(LANGUAGE.strings[i]);
|
|
}
|
|
|
|
return -1;
|
|
} |