2 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "popup_string.h"
21 #include "wrt/src/common/constants.h"
23 #if BUILDFLAG(IS_TIZEN_TV)
24 #include "wrt/src/base/string_utils.h"
29 namespace popup_string {
30 #if BUILDFLAG(IS_TIZEN_TV)
31 const char kPopupTitleAuthRequest[] = "COM_MRMS_CBAGT_MAIN";
32 const char kPopupTitleCert[] = "COM_SID_WEBAPP_CERTIFICATE_INFO";
33 const char kPopupTitleWebNotification[] = "COM_SID_WEBAPP_WEB_NOTIFICATION";
35 const char kPopupBodyAuthRequest[] = "COM_TV_SID_AUTHENICATION_RQEUIRED";
36 const char kPopupBodyCert[] = "COM_TV_SID_PROVLEMS_SECURITY_CERTIFIACATE_SITE";
37 const char kPopupBodyWebNotification[] =
38 "COM_SID_WEBAPP_ALLOWS_WEBSITE_SHOW_NOTIFICATIONS";
40 const char kPopupCheckRememberPreference[] = "TV_SID_REMEMVER_PREFERENCE";
42 const char kPopupLabelAuthusername[] = "COM_TEXT_USER_NAME_P";
43 const char kPopupLabelPassword[] = "COM_SID_PASSWORD";
45 const char kPopupButtonOk[] = "COM_SID_OK";
46 const char kPopupButtonLogin[] = "SID_LOGIN";
47 const char kPopupButtonCancel[] = "COM_SID_CANCEL";
48 const char kPopupButtonAllow[] = "COM_SID_ALLOW";
49 const char kPopupButtonDeny[] = "COM_SID_DENY";
51 const char kPressButtonSearch[] = "TV_SID_3RDPARTY_MIX_PRESS_BUTTON_SEARCH_FOR";
52 const char kSpeechRecognition[] =
53 "TV_SID_3RDPARTY_MIX_AUDIO_SET_ENABLE_SPEECH_RECOGNITION_MSG";
54 const char kMicIcon[] = "COM_ICON_VOICE";
56 const char kPopupTitleAuthRequest[] = "IDS_SA_BODY_USER_AUTHENTICATION";
57 const char kPopupTitleCert[] = "IDS_BR_HEADER_CERTIFICATE_INFO";
58 const char kPopupTitleWebNotification[] =
59 "IDS_BR_HEADER_WEB_NOTIFICATION";
61 const char kPopupBodyAuthRequest[] =
62 "IDS_BR_BODY_DESTINATIONS_AUTHENTICATION_REQUIRED";
63 const char kPopupBodyCert[] =
64 "IDS_BR_BODY_SECURITY_CERTIFICATE_PROBLEM_MSG";
65 const char kPopupBodyWebNotification[] =
66 "IDS_BR_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_SHOW_NOTIFICATIONS";
68 const char kPopupCheckRememberPreference[] =
69 "IDS_BR_BODY_REMEMBER_PREFERENCE";
71 const char kPopupLabelAuthusername[] = "IDS_BR_BODY_AUTHUSERNAME";
72 const char kPopupLabelPassword[] = "IDS_BR_BODY_AUTHPASSWORD";
74 const char kPopupButtonOk[] = "IDS_BR_SK_OK";
75 const char kPopupButtonLogin[] = "IDS_BR_BODY_LOGIN";
76 const char kPopupButtonCancel[] = "IDS_BR_SK_CANCEL";
77 const char kPopupButtonAllow[] = "IDS_BR_OPT_ALLOW";
78 const char kPopupButtonDeny[] = "IDS_COM_BODY_DENY";
80 const char kPopupTitleGeoLocation[] = "IDS_WRT_OPT_ACCESS_USER_LOCATION";
81 const char kPopupTitleUserMedia[] = "IDS_WRT_OPT_USE_USER_MEDIA";
83 const char kPopupBodyGeoLocation[] =
84 "IDS_BR_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_ACCESS_YOUR_LOCATION";
85 const char kPopupBodyUserMedia[] =
86 "IDS_BR_POP_P1SS_HP2SS_IS_REQUESTING_PERMISSION_TO_USE_YOUR_CAMERA";
87 const char kPopupBodyLocalHost[] = "IDS_MF_HEADER_LOCAL";
89 const char kWRTPS[] = "%s";
90 const char kWRTPNS[] = "%d$s";
92 std::string GetText(const std::string& msg_id) {
93 return dgettext(kTextDomainRuntime, msg_id.c_str());
96 #if BUILDFLAG(IS_TIZEN_TV)
97 std::string GetTextAndReplace(const std::string& msg_id,
98 const std::string& replacement) {
99 std::string text = dgettext(kTextDomainRuntime, msg_id.c_str());
100 text = utils::ReplaceAll(text, "<<A>>", replacement);
105 std::string replacePS(std::initializer_list<std::string> strs) {
106 std::size_t size = strs.size();
107 if (size <= 1 || size >= 10) {
108 return std::string("");
110 std::initializer_list<std::string>::iterator it = strs.begin();
111 std::string ret = *strs.begin();
112 std::string arg = *(++it);
115 std::size_t ps = ret.find(kWRTPS);
116 if (ps != std::string::npos) {
117 ret.replace(ps, std::string(kWRTPS).length(), arg);
123 for (; it != strs.end(); ++it) {
124 std::string pns = kWRTPNS;
125 pns.replace(1, 1, n);
127 ret.replace(ret.find(pns), 4, (*it).c_str());
132 } // namespace popup_string