MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / apply_alias

Function apply_alias

src/common/Utility.cpp:328–357  ·  view source on GitHub ↗

Language Aliases

Source from the content-addressed store, hash-verified

326 {L"ZU-ZA", L"isiZulu"}};
327// Language Aliases
328std::pair<std::wstring, bool> apply_alias(std::wstring_view str, LanguageNameStyle style) {
329 if (style == LanguageNameStyle::original)
330 return {std::wstring(str), true};
331
332 std::wstring str_normalized{str};
333 std::replace(str_normalized.begin(), str_normalized.end(), L'_', L'-');
334 auto alias = WinApi::get_locale_info(str_normalized.data(), [&]() {
335 switch (style) {
336 case LanguageNameStyle::english:
337 return LOCALE_SENGLISHDISPLAYNAME;
338 case LanguageNameStyle::localized:
339 return LOCALE_SLOCALIZEDDISPLAYNAME;
340 case LanguageNameStyle::native:
341 return LOCALE_SNATIVEDISPLAYNAME;
342 case LanguageNameStyle::original:
343 case LanguageNameStyle::COUNT:
344 break;
345 }
346 return LOCALE_SENGLISHDISPLAYNAME;
347 }());
348 if (!alias.empty())
349 return {alias, true};
350
351 to_upper_inplace(str_normalized);
352 auto it = alias_map.find(str_normalized);
353 if (it != alias_map.end())
354 return {it->second, true};
355
356 return {std::wstring(str), false};
357}
358
359static bool try_to_create_dir(const wchar_t *path, bool silent, HWND npp_window) {
360 if (!CreateDirectory(path, nullptr)) {

Callers 4

LanguageInfoMethod · 0.85
on_new_file_listMethod · 0.85

Calls 7

get_locale_infoFunction · 0.85
to_upper_inplaceFunction · 0.85
dataMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected