30 if ( sep != boost::string_ref::npos )
50 ret =
IdString( std::string(language_r) +
"_" + country_r.
c_str() );
57 ret =
IdString(
"_" + std::string(country_r) );
73 {
return getIndex( index_r )._l; }
76 {
return getIndex( index_r )._c; }
80 const LC & lc( getIndex( index_r ) );
81 std::string ret( lc.
_l.
name() );
93 static const IdString special(
"pt_BR" );
95 if ( index_r == special )
99 const LC & lc( getIndex( index_r ) );
112 if ( sep != boost::string_ref::npos )
113 code_r = code_r.substr( 0, sep );
118 {
return code_r.find_first_of(
"@." ); }
131 typedef std::unordered_map<IdString,LC>
CodeMap;
140 const LC & getIndex( IdString index_r )
145 CodeMap::value_type newval( index_r, LC() );
147 boost::string_ref str( index_r.c_str() );
149 if ( sep == boost::string_ref::npos )
150 newval.second._l = LanguageCode( index_r );
154 std::string dup( str );
156 newval.second._l = LanguageCode( IdString(str.substr( 0, sep )) );
157 newval.second._c = CountryCode( IdString(str.substr( sep+1 )) );
160 it =
_codeMap.insert( std::move(newval) ).first;
181 : _str( CodeMaps::withoutTrash( str_r ) )
185 : _str( CodeMaps::withoutTrash( str_r ) )
189 : _str( CodeMaps::withoutTrash( str_r ) )
193 : _str( CodeMaps::combineLC( language_r, country_r ) )
200 {
return CodeMaps::instance().language(
_str ); }
203 {
return CodeMaps::instance().country(
_str ); }
206 {
return CodeMaps::instance().name(
_str ); }
215 if ( ! avLocales_r.empty() )
219 for ( ; requested_r; requested_r = requested_r.
fallback() )
221 if ( avLocales_r.count( requested_r ) )