const lines = content.split('\n');
lines.forEach(line => {
const parts = line.split('=');
- if (parts.length === 2) {
- messages[parts[0]] = parts[1];
+ if (parts.length > 1) {
+ messages[parts[0]] = parts.slice(1).join('=');
}
});
return messages;
export function translate(...keys: string[]): string {
const messageKey = keys.join('.');
+ if (process.env.NODE_ENV === 'development') {
+ if (!messages[messageKey]) {
+ console.error(`No message for: ${messageKey}`);
+ }
+ }
return messages[messageKey] || messageKey;
}
.map(parameter => String(parameter))
.reduce((acc, parameter, index) => acc.replace(`{${index}}`, parameter), message);
} else {
+ if (process.env.NODE_ENV === 'development') {
+ console.error(`No message for: ${messageKey}`);
+ }
return `${messageKey}.${parameters.join('.')}`;
}
}