jshmrtn / vue3-gettext

Translate Vue 3 applications with gettext.
https://jshmrtn.github.io/vue3-gettext/
MIT License
70 stars 24 forks source link

fix: handle empty plural translations #51

Closed tabun-matadorov closed 11 months ago

tabun-matadorov commented 11 months ago

In case translation json has empty singular and/or plural strings in the array, the translation function will throw an error. This could potentionally prevent render of vue component.

getTranslationFromArray function is checking for translation string to be falsy value, so it will throw an error if the translation string is empty. According to gettext manual, empty strings should be treated as untranslated.

This commit fixes by checking that translation string is falsy, but not string. For empty strings error is not thrown and untranslated string returned.