Skip to content

Abdulsarhan/Localize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Localization File Format

Limitations: This format only works if all of your strings are utf-8

This library is made up of the generator and the runtime loader. loc_file_gen.c is the generator and loc.h is the loader. The generator takes in a file where you can type in all the strings that you want in all the languages that you want. And converts it to a custom binary file format that gets loaded at runtime. You don't have to understand the generated file format to use this library. But if you're interested, loc_file_gen.c has some documentation about that at the top of the file. To compile the generator, just do: cc loc_file_gen.c -o loc_gen To use the loader, define LOC_IMPLEMENTATION in one file, and include in all the others.

#define LOC_IMPLEMENTATION
#include "loc.h"

Basic Usage for the Localization File Generator

This example generates three files: one for english, one for french, and one for spanish. The format of the file looks like this: shell:

loc_gen strings.txt en fr sp

Where strings.txt looks like this:

hello | bonjour | buenas dias
thank you | merci | Gracias

Basic Usage for the Localization File loader

#include <stdio.h>

#define LOC_IMPLEMENTATION
#include "loc_loader.h"

int main(void) {
    /* loading french localization file */
    loc_file file = loc_load("strings.fr.loc");

    /* null-terminated string. You can just use printf on it */
    const char *loc_string = loc_get_string(&file, "hi there!");
    printf("%s\n", loc_string); /* Bonjour! */

    loc_free(file);

    return 0;
}

About

Small Localization Library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages