43 lines
960 B
C
43 lines
960 B
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "localemanager.h"
|
|
#include "util/memory.h"
|
|
#include "assert/assert.h"
|
|
|
|
localemanager_t LOCALE;
|
|
|
|
errorret_t localeManagerInit() {
|
|
memoryZero(&LOCALE, sizeof(localemanager_t));
|
|
errorChain(localeManagerSetLocale(&LOCALE_EN_US));
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t localeManagerSetLocale(const localeinfo_t *locale) {
|
|
assertNotNull(locale, "Locale cannot be NULL");
|
|
|
|
if(LOCALE.entry != NULL) {
|
|
assetEntryUnlock(LOCALE.entry);
|
|
LOCALE.entry = NULL;
|
|
}
|
|
|
|
LOCALE.locale = locale;
|
|
LOCALE.entry = assetGetEntry(locale->file, ASSET_LOADER_TYPE_LOCALE, NULL);
|
|
assetEntryLock(LOCALE.entry);
|
|
errorChain(assetRequireLoaded(LOCALE.entry));
|
|
|
|
errorOk();
|
|
}
|
|
|
|
void localeManagerDispose() {
|
|
if(LOCALE.entry != NULL) {
|
|
assetEntryUnlock(LOCALE.entry);
|
|
LOCALE.entry = NULL;
|
|
}
|
|
|
|
LOCALE.locale = NULL;
|
|
} |