7#include "iso_15924.hpp"
10#include "../utility/utility.hpp"
11#include "../algorithm/algorithm.hpp"
12#include "../macros.hpp"
19hi_export_module(hikogui.i18n.language_tag : intf);
21hi_export
namespace hi {
inline namespace v1 {
35 uint16_t _reserved = 0;
43 constexpr language_tag(iso_639
const& language,
iso_15924 const& script = {}, iso_3166
const& region = {})
noexcept :
44 language(language), script(script), region(region)
74 return language.empty()
and script.empty()
and region.empty();
94 if (script
and region) {
98 if (script
or region) {
128 for (
auto const variant :
variants()) {
177 r += rhs.language.code();
180 r += rhs.script.code4();
184 r += rhs.region.code2();
193 if (lhs.language
and rhs.language
and lhs.language != rhs.language) {
196 if (lhs.script
and rhs.script
and lhs.script != rhs.script) {
199 if (lhs.region
and rhs.region
and lhs.region != rhs.region) {
233struct std::formatter<
hi::language_tag, char> : std::formatter<std::string_view, char> {
236 return std::formatter<std::string_view, char>::format(
to_string(t), fc);
243struct std::formatter<
std::
vector<hi::language_tag>, char> : std::formatter<std::string_view, char> {
247 for (
auto const language : t) {
251 r += std::format(
"{}", language);
253 return std::formatter<std::string_view, char>::format(r, fc);
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
hi_inline std::vector< language_tag > variants(std::vector< language_tag > languages)
Add variants to the list of languages.
Definition language_tag_impl.hpp:2077
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
ISO-15924 script code.
Definition iso_15924_intf.hpp:23
constexpr bool left_to_right() const noexcept
Is this script written left-to-right.
Definition iso_15924_impl.hpp:349
The IETF BCP 47 language tag.
Definition language_tag_intf.hpp:30
bool empty() const noexcept
Check if the language tag is empty.
Definition language_tag_intf.hpp:72
generator< language_tag > canonical_variants() const noexcept
Get variants of the language_tag.
Definition language_tag_intf.hpp:111
bool left_to_right() const noexcept
The language direction for this language-tag.
Definition language_tag_intf.hpp:169
iso_15924 default_script() const noexcept
Get the default-script for this language.
Definition language_tag_intf.hpp:160
generator< language_tag > variants() const noexcept
Get variants of the language_tag.
Definition language_tag_intf.hpp:91
constexpr friend bool matches(language_tag const &lhs, language_tag const &rhs) noexcept
Check if two language_tags match for their non-empty fields.
Definition language_tag_intf.hpp:191
language_tag expand() const noexcept
Expand the language tag to include script and language.
Definition language_tag_impl.hpp:2043
std::vector< language_tag > all_variants() const noexcept
Creates variants of a language tag, including those by expanding the normal variants.
Definition language_tag_intf.hpp:123
static language_tag parse(std::string_view str)
Parse the language, script and region raw from the string.
Definition language_tag_impl.hpp:1969
language_tag shrink() const noexcept
Get a tag with only the language.
Definition language_tag_intf.hpp:147