Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::LocalisedStrings Class Reference

Translation string lookup — maps keys to localized strings. More...

#include <i18n.hpp>

Public Member Functions

 LocalisedStrings ()=default
bool load_strings_file (std::string_view path)
 Load translations from a .strings file (Apple format: "key" = "value";).
bool load_po_file (std::string_view path)
 Load translations from a .po file (gettext format).
bool load_json_file (std::string_view path)
 Load translations from a JSON file ({"key": "value"}).
void add (std::string_view key, std::string_view value)
 Add a single translation.
std::string translate (std::string_view key) const
 Look up a translation. Returns the key itself if not found.
std::string translate (std::string_view key, const std::vector< std::string > &args) const
 Look up with positional argument substitution.
std::string t (std::string_view key) const
 Shorthand: t("key") == translate("key").
bool has (std::string_view key) const
 Whether a key has a translation.
int count () const
 Number of translations loaded.
void clear ()
 Clear all translations.
const std::string & locale () const
 The locale identifier (e.g., "en", "de", "ja").
void set_locale (std::string_view loc)

Static Public Member Functions

static LocalisedStrings & instance ()
 Get the global translation instance.
static std::string system_locale ()
 Detect the system locale.

Detailed Description

Translation string lookup — maps keys to localized strings.

Constructor & Destructor Documentation

◆ LocalisedStrings()

pulp::runtime::LocalisedStrings::LocalisedStrings ( )
default

Member Function Documentation

◆ add()

void pulp::runtime::LocalisedStrings::add ( std::string_view key,
std::string_view value )

Add a single translation.

◆ clear()

void pulp::runtime::LocalisedStrings::clear ( )
inline

Clear all translations.

◆ count()

int pulp::runtime::LocalisedStrings::count ( ) const
inline

Number of translations loaded.

◆ has()

bool pulp::runtime::LocalisedStrings::has ( std::string_view key) const

Whether a key has a translation.

◆ instance()

LocalisedStrings & pulp::runtime::LocalisedStrings::instance ( )
static

Get the global translation instance.

◆ load_json_file()

bool pulp::runtime::LocalisedStrings::load_json_file ( std::string_view path)

Load translations from a JSON file ({"key": "value"}).

◆ load_po_file()

bool pulp::runtime::LocalisedStrings::load_po_file ( std::string_view path)

Load translations from a .po file (gettext format).

◆ load_strings_file()

bool pulp::runtime::LocalisedStrings::load_strings_file ( std::string_view path)

Load translations from a .strings file (Apple format: "key" = "value";).

◆ locale()

const std::string & pulp::runtime::LocalisedStrings::locale ( ) const
inline

The locale identifier (e.g., "en", "de", "ja").

◆ set_locale()

void pulp::runtime::LocalisedStrings::set_locale ( std::string_view loc)
inline

◆ system_locale()

std::string pulp::runtime::LocalisedStrings::system_locale ( )
static

Detect the system locale.

◆ t()

std::string pulp::runtime::LocalisedStrings::t ( std::string_view key) const
inline

Shorthand: t("key") == translate("key").

◆ translate() [1/2]

std::string pulp::runtime::LocalisedStrings::translate ( std::string_view key) const

Look up a translation. Returns the key itself if not found.

◆ translate() [2/2]

std::string pulp::runtime::LocalisedStrings::translate ( std::string_view key,
const std::vector< std::string > & args ) const

Look up with positional argument substitution.

Replaces {0}, {1}, {2}, ... with the provided arguments.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/i18n.hpp