Just thiknking about how to put it all together.
This commit is contained in:
45
src/locale/language.c
Normal file
45
src/locale/language.c
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "language.h"
|
||||
|
||||
languagestring_t * languageGetStringByKey(language_t *language, char *key) {
|
||||
int32_t i;
|
||||
languagestring_t *string;
|
||||
|
||||
for(i = 0; i < language->stringCount; i++) {
|
||||
string = language->strings + i;
|
||||
if(string->key != key) continue;
|
||||
return string;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * languageGetText(language_t *language, languagestring_t *string) {
|
||||
// Try and find the value
|
||||
|
||||
// Load the value into memory.
|
||||
|
||||
// Return the value
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char * languageGetTextWithVariables(
|
||||
language_t *language, languagestring_t *string, languagevariable_t *variable
|
||||
) {
|
||||
char *text = languageGetText(language, string);
|
||||
if(text == NULL) return NULL;
|
||||
|
||||
// Scan the string, determine the new length and positions of the variables
|
||||
|
||||
// Now create some memory for the new string
|
||||
|
||||
// Now buffer the old string into the new string and take the language
|
||||
|
||||
return text;
|
||||
}
|
31
src/locale/language.h
Normal file
31
src/locale/language.h
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
/**
|
||||
* Returns the language string for a given language string key.
|
||||
*
|
||||
* @param language Language to get from.
|
||||
* @param key Key to get from.
|
||||
* @return The string matching the key, or NULL if no match.
|
||||
*/
|
||||
languagestring_t * languageGetStringByKey(language_t *language, char *key);
|
||||
|
||||
/**
|
||||
* Returns the value for a given language string.
|
||||
*
|
||||
* @param language Language to get from.
|
||||
* @param string Language string to get.
|
||||
* @return The string.
|
||||
*/
|
||||
char * languageGetText(language_t *language, languagestring_t *string);
|
||||
|
||||
char * languageGetTextWithVariables(
|
||||
language_t *language, languagestring_t *string, languagevariable_t *variable
|
||||
);
|
Reference in New Issue
Block a user