| 261 | |
| 262 | public: |
| 263 | inline ELanguage LanguageByName(const TStringBuf& name, ELanguage def) const { |
| 264 | if (!name) |
| 265 | return def; |
| 266 | |
| 267 | TNamesHash::const_iterator i = Hash.find(name); |
| 268 | if (i == Hash.end()) { |
| 269 | // Try to extract the primary language code from constructions like "en-cockney" or "zh_Hant" |
| 270 | size_t dash_pos = name.find_first_of("_-"); |
| 271 | if (dash_pos != TStringBuf::npos) |
| 272 | i = Hash.find(name.substr(0, dash_pos)); |
| 273 | if (i == Hash.end()) |
| 274 | return def; |
| 275 | } |
| 276 | |
| 277 | return i->second; |
| 278 | } |
| 279 | |
| 280 | inline const char* FullNameByLanguage(ELanguage language) const { |
| 281 | if (static_cast<size_t>(language) >= FullNames.size()) |
no test coverage detected