7#include "iso_15924.hpp"
10#include "../utility/utility.hpp"
11#include "../coroutine/module.hpp"
12#include "../algorithm/module.hpp"
13#include "../macros.hpp"
17hi_export_module(hikogui.i18n.language_tag : intf);
19namespace hi {
inline namespace v1 {
33 uint16_t _reserved = 0;
41 constexpr language_tag(iso_639
const& language,
iso_15924 const& script = {}, iso_3166
const& region = {})
noexcept :
42 language(language), script(script), region(region)
72 return language.empty()
and script.empty()
and region.empty();
92 if (script
and region) {
96 if (script
or region) {
174 r += rhs.language.code();
177 r += rhs.script.code4();
181 r += rhs.region.code2();
190 if (lhs.language
and rhs.language
and lhs.language != rhs.language) {
193 if (lhs.script
and rhs.script
and lhs.script != rhs.script) {
196 if (lhs.region
and rhs.region
and lhs.region != rhs.region) {
228hi_export
template<
typename CharT>
229struct std::formatter<
hi::language_tag, CharT> : std::formatter<std::string_view, CharT> {
232 return std::formatter<std::string_view, CharT>::format(
to_string(t), fc);
237hi_export
template<
typename CharT>
238struct std::formatter<
std::
vector<hi::language_tag>, CharT> : std::formatter<std::string_view, CharT> {
242 for (hilet language : t) {
246 r += std::format(
"{}", language);
248 return std::formatter<std::string_view, CharT>::format(r, fc);
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
std::vector< language_tag > variants(std::vector< language_tag > languages)
Add variants to the list of languages.
Definition language_tag_impl.hpp:2069
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
ISO-15924 script code.
Definition iso_15924_intf.hpp:20
constexpr bool left_to_right() const noexcept
Is this script written left-to-right.
Definition iso_15924_impl.hpp:346
The IETF BCP 47 language tag.
Definition language_tag_intf.hpp:28
language_tag expand() const noexcept
Expand the language tag to include script and language.
Definition language_tag_impl.hpp:2035
bool empty() const noexcept
Check if the language tag is empty.
Definition language_tag_intf.hpp:70
generator< language_tag > canonical_variants() const noexcept
Get variants of the language_tag.
Definition language_tag_intf.hpp:109
bool left_to_right() const noexcept
The language direction for this language-tag.
Definition language_tag_intf.hpp:166
iso_15924 default_script() const noexcept
Get the default-script for this language.
Definition language_tag_intf.hpp:157
generator< language_tag > variants() const noexcept
Get variants of the language_tag.
Definition language_tag_intf.hpp:89
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:188
static language_tag parse(std::string_view str)
Parse the language, script and region raw from the string.
Definition language_tag_impl.hpp:1961
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:121
language_tag shrink() const noexcept
Get a tag with only the language.
Definition language_tag_intf.hpp:144