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

wger-project / react / 15069171056

16 May 2025 01:07PM UTC coverage: 76.367% (+0.03%) from 76.336%
15069171056

push

github

web-flow
Merge pull request #1072 from wger-project/fix/improve-translation-handling

Better handling of dynamic translations

1343 of 1963 branches covered (68.42%)

Branch coverage included in aggregate %.

30 of 32 new or added lines in 12 files covered. (93.75%)

7 existing lines in 2 files now uncovered.

5375 of 6834 relevant lines covered (78.65%)

27.97 hits per line

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

78.57
/src/utils/strings.ts
1
const MAX_LENGTH = 22;
135✔
2

3
export function truncateLongNames(name: string, maxLength = MAX_LENGTH): string {
135✔
4
    return name.length > maxLength ? name.slice(0, maxLength) + '…' : name;
4✔
5
}
6

7
// Replace whitespace and parenthesis with underscores and make lowercase
8
//
9
// Note this function is used to generate the translation keys for the exercise categories
10
// etc. so they can be used as keys in the translation files. Don't change the implementation
11
// of this function without updating its counterpart in extract-i18n.py
12
export function makeServerKey(name: string): string {
135✔
13
    return name.toLowerCase()
818✔
14
        .replace(/\s/g, '_')
15
        .replace('(', '_')
16
        .replace(')', '_')
17
        .replace('-', '_');
18
}
19

20
// Returns the key used for the translation of the given exercise data
21
export function getTranslationKey(name: string | undefined): string {
135✔
22
    if (name === undefined) {
812!
UNCOV
23
        console.warn("called getTranslationKey with undefined name");
×
UNCOV
24
        return '';
×
25
    }
26

27
    return `server.${makeServerKey(name)}`;
812✔
28
}
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