martinkr / next-export-i18n

Internationalize (18n) next.js with true support for next export
MIT License
247 stars 37 forks source link

Support for defaultVariables #53

Closed metronome12 closed 1 year ago

metronome12 commented 1 year ago

Is there a way to specify defaultVariables in the configuration?

interpolation: { defaultVariables: {price: 100, product_name:"The product"} }

So that they will be substituted for all values in the language file list so:

{ "product": { "title":"{{product_name}} is the best", "description":"The {{product_name}} is know for efficiency." } }

t('title') would still work without providing product name

and not have to do this:

t('title', {product_name: "The Product"})

martinkr commented 1 year ago

Hi @metronome12 ,

Thank you for reaching out. Maybe using the build-in templating solution could solve your issue?

Let me know if this is helpful, if not I'll take a closer look and try to come up with a solution for your use-case.

Cheers