• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { paramMock } from "../utils"
17
18export function mockI18N() {
19    const i18n = {
20        getDisplayCountry: function(...args) {
21            console.warn("I18N.getDisplayCountry interface mocked in the Previewer. How this interface works on the Previewer" +
22                " may be different from that on a real device.")
23            return paramMock.paramStringMock;
24        },
25        getDisplayLanguage: function(...args) {
26            console.warn("I18N.getDisplayLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
27                " may be different from that on a real device.")
28            return paramMock.paramStringMock;
29        },
30        getSystemLanguages: function() {
31            console.warn("I18N.getSystemLanguages interface mocked in the Previewer. How this interface works on the Previewer" +
32                " may be different from that on a real device.")
33            return new Array(paramMock.paramStringMock);
34        },
35        getSystemCountries: function(...args) {
36            console.warn("I18N.getSystemCountries interface mocked in the Previewer. How this interface works on the Previewer" +
37                " may be different from that on a real device.")
38            return new Array(paramMock.paramStringMock);
39        },
40        isSuggested: function(...args) {
41            console.warn("I18N.isSuggested interface mocked in the Previewer. How this interface works on the Previewer" +
42                " may be different from that on a real device.")
43            return paramMock.paramBooleanMock;
44        },
45        getSystemLanguage: function() {
46            console.warn("I18N.getSystemLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
47                " may be different from that on a real device.")
48            return paramMock.paramStringMock;
49        },
50        setSystemLanguage: function(...args) {
51            console.warn("I18N.setSystemLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
52                " may be different from that on a real device.")
53            return paramMock.paramBooleanMock;
54        },
55        getSystemRegion: function() {
56            console.warn("I18N.getSystemRegion interface mocked in the Previewer. How this interface works on the Previewer" +
57                " may be different from that on a real device.")
58            return paramMock.paramStringMock;
59        },
60        setSystemRegion: function(...args) {
61            console.warn("I18N.setSystemRegion interface mocked in the Previewer. How this interface works on the Previewer" +
62                " may be different from that on a real device.")
63            return paramMock.paramBooleanMock;
64        },
65        getSystemLocale: function() {
66            console.warn("I18N.getSystemLocale interface mocked in the Previewer. How this interface works on the Previewer" +
67                " may be different from that on a real device.")
68            return paramMock.paramStringMock;
69        },
70        setSystemLocale: function(...args) {
71            console.warn("I18N.setSystemLocale interface mocked in the Previewer. How this interface works on the Previewer" +
72                " may be different from that on a real device.")
73            return paramMock.paramBooleanMock;
74        },
75        getCalendar: function(...args) {
76            console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" +
77                " may be different from that on a real device.")
78            return new CalendarClass();
79        },
80        isRTL: function(...args) {
81            console.warn("I18N.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
82                " may be different from that on a real device.")
83            return paramMock.paramBooleanMock;
84        },
85        getLineInstance: function(...args) {
86            console.warn("I18N.getLineInstance interface mocked in the Previewer. How this interface works on the Previewer" +
87                " may be different from that on a real device.")
88            return new BreakIteratorClass();
89        },
90        getTimeZone: function(...args) {
91            console.warn("I18N.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
92                " may be different from that on a real device.")
93            return new TimeZoneClass();
94        },
95        getInstance: function() {
96            console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
97                " may be different from that on a real device.")
98            return new IndexUtilClass();
99        },
100        Character: CharacterClass,
101        is24HourClock: function() {
102            console.warn("I18N.is24HourClock interface mocked in the Previewer. How this interface works on the Previewer" +
103                " may be different from that on a real device.")
104            return paramMock.paramBooleanMock;
105        },
106        set24HourClock: function(...args) {
107            console.warn("I18N.set24HourClock interface mocked in the Previewer. How this interface works on the Previewer" +
108                " may be different from that on a real device.")
109            return paramMock.paramBooleanMock;
110        },
111        addPreferredLanguage: function(...args) {
112            console.warn("I18N.addPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
113                " may be different from that on a real device.")
114            return paramMock.paramBooleanMock;
115        },
116        removePreferredLanguage: function(...args) {
117            console.warn("I18N.removePreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
118                " may be different from that on a real device.")
119            return paramMock.paramBooleanMock;
120        },
121        getPreferredLanguageList: function() {
122            console.warn("I18N.getPreferredLanguageList interface mocked in the Previewer. How this interface works on the Previewer" +
123                " may be different from that on a real device.")
124            return new Array(paramMock.paramStringMock);
125        },
126        getFirstPreferredLanguage: function() {
127            console.warn("I18N.getFirstPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
128                " may be different from that on a real device.")
129            return paramMock.paramStringMock;
130        },
131        TimeZone: TimeZoneClass,
132        setUsingLocalDigit: function(...args) {
133            console.warn("I18N.setUsingLocalDigit interface mocked in the Previewer. How this interface works on the Previewer" +
134                " may be different from that on a real device.")
135            return paramMock.paramBooleanMock;
136        },
137        getUsingLocalDigit: function() {
138            console.warn("I18N.getUsingLocalDigit interface mocked in the Previewer. How this interface works on the Previewer" +
139                " may be different from that on a real device.")
140            return paramMock.paramBooleanMock;
141        },
142        PhoneNumberFormat: PhoneNumberFormatClass,
143        Transliterator: TransliteratorClass,
144        getAppPreferredLanguage: function() {
145            console.warn("I18N.getAppPreferredLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
146                " may be different from that on a real device.")
147            return paramMock.paramStringMock;
148        },
149    }
150    const PhoneNumberFormatOptions = {
151        type: '[PC preview] unknow type',
152    }
153    const UnitInfo = {
154        unit: '[PC preview] unknow unit',
155        measureSystem: '[PC preview] unknow measureSystem',
156    }
157    return i18n;
158}
159
160export const TimeZoneClass = class TimeZone{
161    constructor() {
162        console.warn("I18N.TimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
163            " may be different from that on a real device.")
164        this.getID = function() {
165            console.warn("I18N.TimeZone.getID interface mocked in the Previewer. How this interface works on the Previewer" +
166                " may be different from that on a real device.")
167            return paramMock.paramStringMock;
168        };
169        this.getDisplayName = function(...args) {
170            console.warn("I18N.TimeZone.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
171                " may be different from that on a real device.")
172            return paramMock.paramStringMock;
173        };
174        this.getRawOffset = function() {
175            console.warn("I18N.TimeZone.getRawOffset interface mocked in the Previewer. How this interface works on the Previewer" +
176                " may be different from that on a real device.")
177            return paramMock.paramNumberMock;
178        };
179        this.getOffset = function(...args) {
180            console.warn("I18N.TimeZone.getOffset interface mocked in the Previewer. How this interface works on the Previewer" +
181                " may be different from that on a real device.")
182            return paramMock.paramNumberMock;
183        };
184    }
185}
186TimeZoneClass.getAvailableIDs = function() {
187    console.warn("I18N.TimeZone.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" +
188        " may be different from that on a real device.")
189    return new Array(paramMock.paramStringMock);
190};
191TimeZoneClass.getAvailableZoneCityIDs = function() {
192    console.warn("I18N.TimeZone.getAvailableZoneCityIDs interface mocked in the Previewer. How this interface works on the Previewer" +
193        " may be different from that on a real device.")
194    return new Array(paramMock.paramStringMock);
195};
196TimeZoneClass.getCityDisplayName = function(...args) {
197    console.warn("I18N.TimeZone.getCityDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
198        " may be different from that on a real device.")
199    return paramMock.paramStringMock;
200};
201TimeZoneClass.getTimezoneFromCity = function(...args) {
202    console.warn("I18N.TimeZone.getTimezoneFromCity interface mocked in the Previewer. How this interface works on the Previewer" +
203        " may be different from that on a real device.")
204    return new TimeZoneClass();
205};
206export const PhoneNumberFormatClass = class PhoneNumberFormat{
207    constructor(...args) {
208        console.warn("I18N.PhoneNumberFormat.constructor interface mocked in the Previewer. How this interface works on the Previewer" +
209            " may be different from that on a real device.")
210        this.isValidNumber = function(...args) {
211            console.warn("I18N.PhoneNumberFormat.isValidNumber interface mocked in the Previewer. How this interface works on the Previewer" +
212                " may be different from that on a real device.")
213            return paramMock.paramBooleanMock;
214        };
215        this.format = function(...args) {
216            console.warn("I18N.PhoneNumberFormat.format interface mocked in the Previewer. How this interface works on the Previewer" +
217                " may be different from that on a real device.")
218            return paramMock.paramStringMock;
219        };
220        this.getLocationName = function(...args) {
221            console.warn("I18N.PhoneNumberFormat.getLocationName interface mocked in the Previewer. How this interface works on the Previewer" +
222                " may be different from that on a real device.")
223            return paramMock.paramStringMock;
224        };
225    }
226}
227export const TransliteratorClass = class Transliterator {
228    constructor() {
229        console.warn("I18N.Transliterator interface mocked in the Previewer. How this interface works on the Previewer" +
230            " may be different from that on a real device.")
231        this.transform = function(...args) {
232            console.warn("I18N.Transliterator.transform interface mocked in the Previewer. How this interface works on the Previewer" +
233                " may be different from that on a real device.")
234            return paramMock.paramStringMock;
235        };
236    }
237}
238TransliteratorClass.getAvailableIDs = function() {
239    console.warn("I18N.Transliterator.getAvailableIDs interface mocked in the Previewer. How this interface works on the Previewer" +
240        "may be different from that on a real device.")
241    return new Array(paramMock.paramStringMock);
242}
243TransliteratorClass.getInstance = function(...args) {
244    console.warn("I18N.Transliterator.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
245        "may be different from that on a real device.")
246    return new TransliteratorClass();
247}
248const IndexUtilClass = class IndexUtil {
249    constructor() {
250        console.warn("I18N.IndexUtil interface mocked in the Previewer. How this interface works on the Previewer" +
251            " may be different from that on a real device.")
252        this.getIndexList = function() {
253            console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" +
254                " may be different from that on a real device.")
255            return new Array(paramMock.paramStringMock);
256        };
257        this.addLocale = function(...args) {
258            console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" +
259                " may be different from that on a real device.")
260        };
261        this.getIndex = function(...args) {
262            console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" +
263                " may be different from that on a real device.")
264            return paramMock.paramStringMock;
265        };
266    }
267}
268const BreakIteratorClass = class BreakIterator {
269    constructor() {
270        console.warn("I18N.BreakIterator interface mocked in the Previewer. How this interface works on the Previewer" +
271            " may be different from that on a real device.")
272        this.current = function() {
273            console.warn("I18N.BreakIterator.current interface mocked in the Previewer. How this interface works on the Previewer" +
274                " may be different from that on a real device.")
275            return paramMock.paramNumberMock;
276        };
277        this.first = function() {
278            console.warn("I18N.BreakIterator.first interface mocked in the Previewer. How this interface works on the Previewer" +
279                " may be different from that on a real device.")
280            return paramMock.paramNumberMock;
281        };
282        this.last = function() {
283            console.warn("I18N.BreakIterator.last interface mocked in the Previewer. How this interface works on the Previewer" +
284                " may be different from that on a real device.")
285            return paramMock.paramNumberMock;
286        };
287        this.next = function(...args) {
288            console.warn("I18N.BreakIterator.next interface mocked in the Previewer. How this interface works on the Previewer" +
289                " may be different from that on a real device.")
290            return paramMock.paramNumberMock;
291        };
292        this.previous = function() {
293            console.warn("I18N.BreakIterator.previous interface mocked in the Previewer. How this interface works on the Previewer" +
294                " may be different from that on a real device.")
295            return paramMock.paramNumberMock;
296        };
297        this.setLineBreakText = function() {
298            console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
299                " may be different from that on a real device.")
300        };
301        this.following = function() {
302            console.warn("I18N.BreakIterator.following interface mocked in the Previewer. How this interface works on the Previewer" +
303                " may be different from that on a real device.")
304            return paramMock.paramNumberMock;
305        };
306        this.getLineBreakText = function() {
307            console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
308                " may be different from that on a real device.")
309            return paramMock.paramStringMock;
310        };
311        this.isBoundary = function(...args) {
312            console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" +
313                " may be different from that on a real device.")
314            return paramMock.paramBooleanMock;
315        };
316    }
317}
318const CalendarClass = class Calendar {
319    constructor() {
320        console.warn("I18N.Calendar interface mocked in the Previewer. How this interface works on the Previewer" +
321            " may be different from that on a real device.")
322        this.setTime = function(...args) {
323            console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
324                " may be different from that on a real device.")
325        };
326        this.set = function(...args) {
327            console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" +
328                " may be different from that on a real device.")
329        };
330        this.setTimeZone = function(...args) {
331            console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
332                " may be different from that on a real device.")
333        };
334        this.getTimeZone = function() {
335            console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
336                " may be different from that on a real device.")
337            return paramMock.paramStringMock;
338        };
339        this.getFirstDayOfWeek = function() {
340            console.warn("I18N.Calendar.getFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
341                " may be different from that on a real device.")
342            return paramMock.paramNumberMock;
343        };
344        this.setFirstDayOfWeek = function(...args) {
345            console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
346                " may be different from that on a real device.")
347        };
348        this.getMinimalDaysInFirstWeek = function() {
349            console.warn("I18N.Calendar.getMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
350                " may be different from that on a real device.")
351            return paramMock.paramNumberMock;
352        };
353        this.setMinimalDaysInFirstWeek = function(...args) {
354            console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
355                " may be different from that on a real device.")
356        };
357        this.get = function(...args) {
358            console.warn("I18N.Calendar.get interface mocked in the Previewer. How this interface works on the Previewer" +
359                " may be different from that on a real device.")
360            return paramMock.paramNumberMock;
361        };
362        this.getDisplayName = function(...args) {
363            console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
364                " may be different from that on a real device.")
365            return paramMock.paramStringMock;
366        };
367        this.isWeekend = function(...args) {
368            console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" +
369                " may be different from that on a real device.")
370            return paramMock.paramBooleanMock;
371        };
372    }
373}
374export const UtilClass = class Util {
375    constructor() {
376        console.warn("I18N.Util interface mocked in the Previewer. How this interface works on the Previewer" +
377            " may be different from that on a real device.")
378        this.unitConvert = function(...args) {
379            console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" +
380                " may be different from that on a real device.")
381            return paramMock.paramStringMock;
382        };
383        this.getDateOrder = function(...args) {
384            console.warn("I18N.Util.getDateOrder interface mocked in the Previewer. How this interface works on the Previewer" +
385                " may be different from that on a real device.")
386            return paramMock.paramStringMock;
387        }
388    }
389}
390export const CharacterClass = class Character {
391    constructor() {
392        console.warn("I18N.Character interface mocked in the Previewer. How this interface works on the Previewer" +
393            " may be different from that on a real device.")
394        this.isDigit = function(...args) {
395            console.warn("I18N.Character.isDigit interface mocked in the Previewer. How this interface works on the Previewer" +
396                " may be different from that on a real device.")
397            return paramMock.paramBooleanMock;
398        };
399        this.isSpaceChar = function(...args) {
400            console.warn("I18N.Character.isSpaceChar interface mocked in the Previewer. How this interface works on the Previewer" +
401                " may be different from that on a real device.")
402            return paramMock.paramBooleanMock;
403        };
404        this.isWhitespace = function(...args) {
405            console.warn("I18N.Character.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" +
406                " may be different from that on a real device.")
407            return paramMock.paramBooleanMock;
408        };
409        this.isRTL = function(...args) {
410            console.warn("I18N.Character.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
411                " may be different from that on a real device.")
412            return paramMock.paramBooleanMock;
413        };
414        this.isIdeograph = function(...args) {
415            console.warn("I18N.Character.isIdeograph interface mocked in the Previewer. How this interface works on the Previewer" +
416                " may be different from that on a real device.")
417            return paramMock.paramBooleanMock;
418        };
419        this.isLetter = function(...args) {
420            console.warn("I18N.Character.isLetter interface mocked in the Previewer. How this interface works on the Previewer" +
421                " may be different from that on a real device.")
422            return paramMock.paramBooleanMock;
423        };
424        this.isLowerCase = function(...args) {
425            console.warn("I18N.Character.isLowerCase interface mocked in the Previewer. How this interface works on the Previewer" +
426                " may be different from that on a real device.")
427            return paramMock.paramBooleanMock;
428        };
429        this.isUpperCase = function(...args) {
430            console.warn("I18N.Character.isUpperCase interface mocked in the Previewer. How this interface works on the Previewer" +
431                " may be different from that on a real device.")
432            return paramMock.paramBooleanMock;
433        };
434        this.getType = function(...args) {
435            console.warn("I18N.Character.getType interface mocked in the Previewer. How this interface works on the Previewer" +
436                " may be different from that on a real device.")
437            return paramMock.paramStringMock;
438        };
439    }
440}