libborr
A simple translation parser for C++
|
!!! CURRENTLY WORK IN PROGRESS !!!
libborr is a language file parsing library which allows you to easily translate your C++ application to any language(s) you might need to! libboor uses regular expressions to efficiently and easily parse .borr (or .lang) files with their special structure to ensure you always know which language you're selecting and provides a super simple API to use.
Please not this is not the real documentation, but an excerpt of the code docs! This will updated shortly!
This class represents a single language which is parsed from a language file (typically *.borr or *.lang). A language file is a psuedo-ini format which allows for comments, multi-line strings and variable (string) replacement.
Before a language file switches from being a simple ini file to a language file, it must meet the following criteria:
In the main scope:
Language files can contain different structures which allow them to be flexible and usable in a variety of domains. Here is a list of all structures a language file can (or sometimes must) contain for it to be valid.
Structure | Description | Example |
---|---|---|
lang_desc | The language description description field. | lang_desc = "English (United Kingdom)" |
lang_id | The language ID with region and country. | lang_id = "en_GB" |
lang_ver | The language file's current version. | lang_ver = "v1.0.0" (v is optional!) |
# | A comment. Comments can start anywhere. | # this is a comment in my langfile |
[section] | A new language section; for pages or menus. | [home_page] # translations for home page |
field | A field is a string container | page_title = "My Home Page!" |
field[] | A multi-line field. | about[] = "This is an example of multi-" |
field[] | A multi-line field. | about[] = "line translation fields." |
${} | A variable; used for text replacement. | awesome = "${page_title} Is Awesome!" |
${} | A special variable; used for text replacement. | copyright = "© ${year}" |
libborr provides a plethora of features for parsing and using borr files and is extensible by use of modern C++ features, such as lambdas.
Here is an example of using libborr for parsing your language files.
With those two files, you could call something like this from within your application:
And that's basically the main API. It's rare you'll need much more than that.