MCPcopy
hub / github.com/1j01/jspaint / find_localization

Function find_localization

src/app-localization.js:18–39  ·  view source on GitHub ↗
(english_text)

Source from the content-addressed store, hash-verified

16 */
17 function localize(english_text, ...interpolations) {
18 function find_localization(english_text) {
19 if (AccessKeys.has(english_text)) {
20 const without_hotkey = AccessKeys.remove(english_text);
21 if (localizations[without_hotkey]) {
22 const hotkey_def = AccessKeys.get(english_text);
23 if (localizations[without_hotkey].toUpperCase().indexOf(hotkey_def.toUpperCase()) > -1) {
24 return localizations[without_hotkey];
25 } else {
26 if (AccessKeys.has(localizations[without_hotkey])) {
27 // window.console?.warn(`Localization has differing access key hint: '${localizations[without_hotkey]}' vs '${english_text}'`);
28 // @TODO: detect differing access key more generally
29 return `${AccessKeys.remove(localizations[without_hotkey])} (${hotkey_def})`;
30 }
31 return `${localizations[without_hotkey]} (${hotkey_def})`;
32 }
33 }
34 }
35 if (localizations[english_text]) {
36 return localizations[english_text];
37 }
38 return english_text;
39 }
40 function interpolate(text, interpolations) {
41 for (let i = 0; i < interpolations.length; i++) {
42 text = text.replace(`%${i + 1}`, interpolations[i]);

Callers 1

localizeFunction · 0.85

Calls 5

hasMethod · 0.80
indexOfMethod · 0.80
toUpperCaseMethod · 0.80
removeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected