svelte-i18n icon indicating copy to clipboard operation
svelte-i18n copied to clipboard

Allow return of empty translations

Open FilipJakab opened this issue 3 years ago • 3 comments

Hello, is it possible to allow empty translations? By a quick look I think this is the relevant code: https://github.com/kaisermann/svelte-i18n/blob/0516bb417c4d510e5cd5d225b60cb6ad469118a5/src/runtime/includes/lookup.ts#L31

In my case, it currently works like this: With translations:

{
  "translations": {
    "translation": ""
  }
}

the result of $_("translations.translation") is translations.translation

Thanks

FilipJakab avatar Oct 06 '22 16:10 FilipJakab

We would also appreciate this, tbh. There’s a couple of possible fixes for it:

if (message != null) {
  // …
}

Better, I think, would be checking for a string value (because $_("translations") shouldn’t really be rendered, should it?):

if (typeof message === 'string') {
  // …
}

halostatue avatar Jan 04 '23 22:01 halostatue

+1

It is however a breaking change, as my doesTranslationExist function checks if t(key) !== key, which hopefully won't be the case anymore if this is fixed.

lukasvan3l avatar Dec 18 '23 09:12 lukasvan3l