i18n
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ILocale Class Referenceabstract

Base interface for all locale implementations. More...

#include <ILocale.hpp>

Inherited by DefaultLocale.

Public Member Functions

virtual const std::string languageCode () const =0
 Retrieve the two-letter language code of the locale.
 
virtual ~ILocale ()=default
 Virtual destructor for proper cleanup of derived classes.
 
virtual const std::string languageCode () const =0
 Retrieve the two-letter language code of the locale.
 
virtual ~ILocale ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Detailed Description

Base interface for all locale implementations.

Defines the minimal contract that a locale type must provide. Each locale should inherit from this class and implement languageCode().

Example usage:

// see LocaleInterface.
class DefaultLocale : public ILocale {
public:
virtual const std::string homePageTitle() const = 0;
};
// in I18n<T> see DerivedFrom<T> where T is DefaultLocale.
class EnLocale : public DefaultLocale {
public:
const std::string languageCode() const override { return "en"; }
const std::string homePageTitle() const override { return "Welcome"; }
};
Base interface for all locale implementations.
Definition ILocale.hpp:34
Examples
DefaultLocale.hpp.

Constructor & Destructor Documentation

◆ ~ILocale() [1/2]

virtual ILocale::~ILocale ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

◆ ~ILocale() [2/2]

virtual ILocale::~ILocale ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ languageCode() [1/2]

virtual const std::string ILocale::languageCode ( ) const
pure virtual

Retrieve the two-letter language code of the locale.

Note
example: "en" -> English, "fr" -> French, "es" -> Spanish.
Returns
std::string Two-letter ISO language code.
Examples
DefaultLocale.hpp.

◆ languageCode() [2/2]

virtual const std::string ILocale::languageCode ( ) const
pure virtual

Retrieve the two-letter language code of the locale.

Note
example: "en" -> English, "fr" -> French, "es" -> Spanish.
Returns
std::string Two-letter ISO language code.

The documentation for this class was generated from the following files: