diff --git a/README.md b/README.md index 18ffc4b..7d6f54e 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,15 @@ We can also add a comment for the translators reading the message catalog e.g. t })} ``` +Also, if you need to interpolate dynamic values into the message, you can use the `values` property in the MessageDescriptor object: + +```svelte +{$t({ + message: 'Hello {name}!', + values: { name: 'World' } +})} +``` + ### Plurals To provide different messages for text with numbers, use the provided `$plural` store: diff --git a/src/lib/index.js b/src/lib/index.js index 8c874eb..f164daf 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -4,6 +4,7 @@ * @property {string} message - The message to be translated. * @property {string} [context] - The context of the message, will be included in the po file. The same message with different context will be extracted as separate entries, and can be translated differently. * @property {string} [comment] - A comment purely for giving information to the translator, won't affect translated string. + * @property {Record} [values] - An optional dictionary of values to be used in the message. */ import { writable, derived } from 'svelte/store';