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
18namespace OHOS::Ace {
19namespace {
20constexpr int32_t DAY_COUNTS_OF_WEEK = 7;
21constexpr int32_t MONTH_COUNTS_OF_YEAR = 12;
22} // namespace
23
24struct LocaleProxy final {};
25Localization::~Localization() = default;
26
27void Localization::SetLocaleImpl(const std::string& language, const std::string& countryOrRegion,
28    const std::string& script, const std::string& selectLanguage, const std::string& keywordsAndValues)
29{
30    languageTag_ = language;
31}
32
33std::string Localization::GetFontLocale()
34{
35    return fontLocale_;
36}
37
38std::shared_ptr<Localization> Localization::GetInstance()
39{
40    static auto instance = std::make_shared<Localization>();
41    return instance;
42}
43
44bool Localization::GetDateOrder(std::vector<std::string>& outOrder)
45{
46    outOrder.clear();
47    if (languageTag_ == "ug") {
48        outOrder.emplace_back("month");
49        outOrder.emplace_back("day");
50        outOrder.emplace_back("year");
51    } else if (languageTag_ == "zh") {
52        outOrder.emplace_back("year");
53        outOrder.emplace_back("month");
54        outOrder.emplace_back("day");
55    } else if (languageTag_ == "false") {
56        return false;
57    }
58    return true;
59}
60
61std::string Localization::FormatDuration(uint32_t duration, const std::string& format)
62{
63    return "08:00:00";
64}
65
66const std::string Localization::FormatDateTime(DateTime dateTime, const std::string& format)
67{
68    return "08:00:00";
69}
70
71const std::string Localization::FormatDateTime(DateTime dateTime, DateTimeStyle dateStyle, DateTimeStyle timeStyle)
72{
73    return "08:00:00";
74}
75
76std::string Localization::GetEntryLetters(const std::string& lettersIndex)
77{
78    return "";
79}
80
81std::string Localization::GetErrorDescription(const std::string& errorIndex)
82{
83    return "";
84}
85
86const std::string Localization::FormatDuration(uint32_t duration, bool needShowHour)
87{
88    return "08:00:00";
89}
90
91std::vector<std::string> Localization::GetMonths(bool isShortType, const std::string& calendarType)
92{
93    std::vector<std::string> months;
94    for (int32_t i = 0; i < MONTH_COUNTS_OF_YEAR; i++) {
95        months.push_back(std::to_string(i));
96    }
97    return months;
98}
99
100std::string Localization::GetLanguage()
101{
102    return "Chinese";
103}
104
105std::string Localization::GetLunarMonth(uint32_t month, bool isLeapMonth)
106{
107    return "";
108}
109
110std::string Localization::GetLunarDay(uint32_t dayOfMonth)
111{
112    return "";
113}
114
115LunarDate Localization::GetLunarDate(Date date)
116{
117    LunarDate dateRet;
118    dateRet.year = date.year;
119    dateRet.month = date.month;
120    dateRet.day = date.day;
121    return dateRet;
122}
123
124std::vector<std::string> Localization::GetAmPmStrings()
125{
126    std::vector<std::string> amPms;
127    return amPms;
128}
129
130bool Localization::GetHourFormat(bool& isAmPm, bool& hasZero)
131{
132    return false;
133}
134
135// Mock get weekdays, 7 days in a week.
136std::vector<std::string> Localization::GetWeekdays(bool isShortType)
137{
138    std::vector<std::string> weekdays;
139    for (int32_t i = 0; i < DAY_COUNTS_OF_WEEK; i++) {
140        weekdays.push_back(std::to_string(i));
141    }
142    return weekdays;
143}
144
145std::string Localization::NumberFormat(double number)
146{
147    return std::to_string(number);
148}
149} // namespace OHOS::Ace
150