Text Lookup Interface

Used for storing and looking up localized strings. Uses an ini-file like file format for localization lookup.

struct text_lookup
typedef struct text_lookup lookup_t
#include <util/text-lookup.h>

Text Lookup Functions

lookup_t *text_lookup_create(const char *path)

Creates a text lookup object from a text lookup file.

Parameters:
  • path – Path to the localization file

Returns:

New lookup object, or NULL if an error occurred


bool text_lookup_add(lookup_t *lookup, const char *path)

Adds text lookup from a text lookup file and replaces any values. For example, you would load a default fallback language such as english with text_lookup_create(), and then call this function to load the actual desired language in case the desired language isn’t fully translated.

Parameters:
  • lookup – Lookup object

  • path – Path to the localization file

Returns:

true if successful, false otherwise


void text_lookup_destroy(lookup_t *lookup)

Destroys a text lookup object.

Parameters:
  • lookup – Lookup object


bool text_lookup_getstr(lookup_t *lookup, const char *lookup_val, const char **out)

Gets a localized text string.

Parameters:
  • lookup – Lookup object

  • lookup_val – Value to look up

  • out – Pointer that receives the translated string pointer

Returns:

true if the value exists, false otherwise