• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jumpinjackie / mapguide-react-layout / 15160437878

21 May 2025 11:00AM UTC coverage: 21.631% (-42.6%) from 64.24%
15160437878

Pull #1552

github

web-flow
Merge 8b7153d9e into 236e2ea07
Pull Request #1552: Feature/package updates 2505

839 of 1165 branches covered (72.02%)

11 of 151 new or added lines in 25 files covered. (7.28%)

1332 existing lines in 50 files now uncovered.

4794 of 22163 relevant lines covered (21.63%)

6.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.19
/src/api/i18n.ts
1
import { STRINGS_EN } from "../strings/en";
1✔
2
import { ILocalizedMessages } from "../strings/msgdef";
3
import { warn } from '../utils/logger';
1✔
4

5
export const DEFAULT_LOCALE = "en";
1✔
6

7
const STRINGS: { [locale: string]: ILocalizedMessages } = {
1✔
8
    "en": STRINGS_EN
1✔
9
};
1✔
10

11
/**
12
 * Registers a string bundle for the given locale
13
 *
14
 * @export
15
 * @param {string} locale
16
 * @param {ILocalizedMessages} bundle
17
 */
18
export function registerStringBundle(locale: string, bundle: ILocalizedMessages) {
1✔
19
    STRINGS[locale] = bundle;
×
UNCOV
20
}
×
21

22
/**
23
 * Formats the specified string and substitutes any placeholders (enclosed in {})
24
 * with the specified arguments
25
 *
26
 * @export
27
 * @param {string} format
28
 * @param {*} [args]
29
 * @returns {string}
30
 */
31
export function fmt(format: string, args?: any): string {
1✔
32
    let str = format;
31✔
33
    if (args != null) {
31✔
34
        for (const p in args) {
30✔
35
            //str = str.replace(new RegExp(`\{${p}\}`, "g"), `${args[p]}`);
36
            str = str.split(`{${p}}`).join(args[p]);
55✔
37
        }
55✔
38
        return str;
30✔
39
    };
31✔
40
    return str;
1✔
41
}
1✔
42

43

44
/**
45
 * Returns the localized string for the given key
46
 * 
47
 * @export
48
 * @param {keyof ILocalizedMessages} key Any property name of {@link ILocalizedMessages}
49
 * @param {string} [locale="en"] 
50
 * @param {*} [args] If a localized string has placeholders, they will be replaced with the values defined here
51
 * @returns {string} 
52
 */
53
export function tr(key: keyof ILocalizedMessages, locale = DEFAULT_LOCALE, args?: any): string {
1✔
54
    const bundle = STRINGS[locale];
214✔
55
    if (!bundle) {
214✔
56
        warn(`No such string bundle for locale: ${locale}`);
6✔
57
        return key;
6✔
58
    } else {
209✔
59
        let str = bundle[key];
208✔
60
        if (!str) {
208!
61
            warn(`String bundle for locale (${locale}) is missing localized string for key: ${key}`);
×
62
            return key;
×
63
        } else {
208✔
64
            if (args != null) {
208✔
65
                return fmt(str, args);
13✔
66
            }
13✔
67
            return str;
195✔
68
        }
195✔
69
    }
208✔
70
}
214✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc