• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
16 #ifndef OHOS_GLOBAL_I18N_LOCALE_INFO_ADDON_H
17 #define OHOS_GLOBAL_I18N_LOCALE_INFO_ADDON_H
18 
19 #include "ani.h"
20 #include "locale_info.h"
21 
22 namespace OHOS {
23 namespace Global {
24 namespace I18n {
25 class LocaleInfoAddon {
26 public:
27     static LocaleInfoAddon* UnwrapAddon(ani_env *env, ani_object object, const std::string &name);
28     template<typename T>
29     static T GetLocaleProperty(ani_env *env, ani_object object,
30         const std::string &propertyName, T (LocaleInfo::*getter)() const);
31     static ani_string Locale_ToString(ani_env *env, ani_object object);
32     static ani_object Locale_Maximize(ani_env *env, ani_object object);
33     static ani_object Locale_Minimize(ani_env *env, ani_object object);
34     static ani_string Locale_GetLanguage(ani_env *env, ani_object object);
35     static ani_string Locale_GetScript(ani_env *env, ani_object object);
36     static ani_string Locale_GetRegion(ani_env *env, ani_object object);
37     static ani_string Locale_GetBaseName(ani_env *env, ani_object object);
38     static ani_string Locale_GetCaseFirst(ani_env *env, ani_object object);
39     static ani_string Locale_GetCalendar(ani_env *env, ani_object object);
40     static ani_string Locale_GetCollation(ani_env *env, ani_object object);
41     static ani_string Locale_GetHourCycle(ani_env *env, ani_object object);
42     static ani_string Locale_GetNumberingSystem(ani_env *env, ani_object object);
43     static ani_boolean Locale_GetNumeric(ani_env *env, ani_object object);
44     static ani_object Locale_Create(ani_env *env, [[maybe_unused]] ani_object object);
45     static ani_object Locale_CreateWithParam(ani_env *env, [[maybe_unused]] ani_object object,
46         ani_string locale, ani_object options);
47     static ani_status BindContext_Locale(ani_env *env);
48 
GetLocaleInfo()49     std::shared_ptr<LocaleInfo> GetLocaleInfo()
50     {
51         if (!this->locale_) {
52             return nullptr;
53         }
54         return this->locale_;
55     }
56 private:
57     std::shared_ptr<LocaleInfo> locale_ = nullptr;
58 };
59 } // namespace I18n
60 } // namespace Global
61 } // namespace OHOS
62 #endif
63