Skip to content

Conversation

@xavierdeneux
Copy link

@xavierdeneux xavierdeneux commented Feb 18, 2025

🤔 Why?

I saw an error with one of my preview for EPG and the root cause was the title of the box contained the "%" chars.
Because of this char, the sprintf command failed.

t('my_translation_string%') does not work
(In fact, in my original case, the "translation string" is not really a translation key but an already translated key like t('Mon super programme 100% cool')

image

💻 How?

Escape the "%" chars to prevent sprintf command to crash.

const translatedResult = sprintf(translation, { ...data, ...i18nNames, number });
// escape special characters (% for now)
const translationValues = _mapValues({ ...data, ...i18nNames, number }, value => {
if (value) {
Copy link

@qtomasicchio qtomasicchio Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the unit test, value can be a number. We should probably check that we have a string, what do you think?

Suggested change
if (value) {
if (typeof value === 'string') {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants