MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / interpolate

Method interpolate

src/i18n.ts:67–76  ·  view source on GitHub ↗

* Interpolate values into a string template * Supports {{key}} syntax * @param template - String template with {{key}} placeholders * @param values - Values to interpolate * @returns Interpolated string

(template: string, values?: TranslationValues)

Source from the content-addressed store, hash-verified

65 * @returns Interpolated string
66 */
67 private interpolate(template: string, values?: TranslationValues): string {
68 if (!values) {
69 return template;
70 }
71
72 return template.replace(/\{\{(\w+)\}\}/g, (match, key) => {
73 const value = values[key];
74 return value !== undefined ? String(value) : match;
75 });
76 }
77
78 /**
79 * Add or update translations for a specific locale

Callers 1

tMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected