1 /*
2 * Copyright (c) 2021-2022 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 #include "base/i18n/localization.h"
17
18 namespace OHOS::Ace {
19 namespace {
20 constexpr int32_t DAY_COUNTS_OF_WEEK = 7;
21 } // namespace
22
23 struct LocaleProxy final {};
24 Localization::~Localization() = default;
25
GetFontLocale()26 std::string Localization::GetFontLocale()
27 {
28 return fontLocale_;
29 }
30
GetInstance()31 std::shared_ptr<Localization> Localization::GetInstance()
32 {
33 static auto instance = std::make_shared<Localization>();
34 return instance;
35 }
36
FormatDuration(uint32_t duration,const std::string & format)37 std::string Localization::FormatDuration(uint32_t duration, const std::string& format)
38 {
39 return "08:00:00";
40 }
41
FormatDateTime(DateTime dateTime,const std::string & format)42 const std::string Localization::FormatDateTime(DateTime dateTime, const std::string& format)
43 {
44 return "08:00:00";
45 }
46
FormatDateTime(DateTime dateTime,DateTimeStyle dateStyle,DateTimeStyle timeStyle)47 const std::string Localization::FormatDateTime(DateTime dateTime, DateTimeStyle dateStyle, DateTimeStyle timeStyle)
48 {
49 return "08:00:00";
50 }
51
GetEntryLetters(const std::string & lettersIndex)52 std::string Localization::GetEntryLetters(const std::string& lettersIndex)
53 {
54 return "";
55 }
56
GetErrorDescription(const std::string & errorIndex)57 std::string Localization::GetErrorDescription(const std::string& errorIndex)
58 {
59 return "";
60 }
61
FormatDuration(uint32_t duration,bool needShowHour)62 const std::string Localization::FormatDuration(uint32_t duration, bool needShowHour)
63 {
64 return "08:00:00";
65 }
66
GetMonths(bool isShortType,const std::string & calendarType)67 std::vector<std::string> Localization::GetMonths(bool isShortType, const std::string& calendarType)
68 {
69 std::vector<std::string> months;
70 return months;
71 }
72
GetLanguage()73 std::string Localization::GetLanguage()
74 {
75 return "Chinese";
76 }
77
GetLunarMonth(uint32_t month,bool isLeapMonth)78 std::string Localization::GetLunarMonth(uint32_t month, bool isLeapMonth)
79 {
80 return "";
81 }
82
GetLunarDay(uint32_t dayOfMonth)83 std::string Localization::GetLunarDay(uint32_t dayOfMonth)
84 {
85 return "";
86 }
87
GetLunarDate(Date date)88 LunarDate Localization::GetLunarDate(Date date)
89 {
90 LunarDate dateRet;
91 dateRet.year = date.year;
92 dateRet.month = date.month;
93 dateRet.day = date.day;
94 return dateRet;
95 }
96
GetAmPmStrings()97 std::vector<std::string> Localization::GetAmPmStrings()
98 {
99 std::vector<std::string> amPms;
100 return amPms;
101 }
102
GetHourFormat(bool & isAmPm,bool & hasZero)103 bool Localization::GetHourFormat(bool& isAmPm, bool& hasZero)
104 {
105 return false;
106 }
107
108 // Mock get weekdays, 7 days in a week.
GetWeekdays(bool isShortType)109 std::vector<std::string> Localization::GetWeekdays(bool isShortType)
110 {
111 std::vector<std::string> weekdays;
112 for (int32_t i = 0; i < DAY_COUNTS_OF_WEEK; i++) {
113 weekdays.push_back(std::to_string(i));
114 }
115 return weekdays;
116 }
117
NumberFormat(double number)118 std::string Localization::NumberFormat(double number)
119 {
120 return std::to_string(number);
121 }
122 } // namespace OHOS::Ace
123