1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_GLOBAL_I18N_LOCALE_COMPARE_H 16 #define OHOS_GLOBAL_I18N_LOCALE_COMPARE_H 17 18 #include <map> 19 #include <set> 20 #include <string> 21 #include "unicode/locid.h" 22 23 namespace OHOS { 24 namespace Global { 25 namespace I18n { 26 class LocaleCompare { 27 public: 28 static int32_t Compare(const std::string& localeTag1, const std::string& localeTag2); 29 30 private: 31 static bool IsSameLanguage(const std::string& langTag1, const std::string& langTag2); 32 static bool IsSameEnglishScript(const std::string& scriptTag1, const std::string& scriptTag2); 33 static bool HasMapRelation(const std::string& languageTag, const std::string& localeTag1, 34 const std::string& localeTag2); 35 static bool IsBaseNameRelation(const char* baseName1, const char* baseName2, 36 const std::string& languageTag); 37 static std::string hantSegment; 38 static std::string latnSegment; 39 static std::string qaagSegment; 40 static std::set<std::string> scriptLocales; 41 static std::map<std::string, std::string> hantParent; 42 static std::map<std::string, std::string> latnParent; 43 static std::map<std::string, std::string> extendedHantParent; 44 static std::map<std::string, std::string> extendedLatnParent; 45 }; 46 } // namespace I18n 47 } // namespace Global 48 } // namespace OHOS 49 #endif