Locale.h (1259B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <string> 5 #include <vector> 6 7 namespace AppInstaller::Locale 8 { 9 static constexpr double MinimumDistanceScoreAsPerfectMatch = 1.0; 10 static constexpr double MinimumDistanceScoreAsCompatibleMatch = 0.9; 11 static constexpr double UnknownLanguageDistanceScore = 0.0; 12 13 // Check if a bcp47 language tag is well formed 14 bool IsWellFormedBcp47Tag(std::string_view bcp47Tag); 15 16 // Get a score of language distance between target and available. The return value range is 0 to 1. 17 // With 1 meaning perfect match and 0 meaning no match. 18 double GetDistanceOfLanguage(std::string_view target, std::string_view available); 19 20 // Get the list of user Preferred Languages from settings. Returns an empty vector in rare cases of failure. 21 std::vector<std::string> GetUserPreferredLanguages(); 22 23 // Get the list of user Preferred Languages from settings. Returns an empty vector in rare cases of failure. 24 std::vector<std::wstring> GetUserPreferredLanguagesUTF16(); 25 26 // Get the bcp47 tag from a locale id. Returns empty string if conversion cannot be performed. 27 std::string LocaleIdToBcp47Tag(LCID localeId); 28 }