Skip to content

[EuiI18n] Fixed EuiContext.i18n's mappingFunc not being called for EuiI18n with multiple tokens and function callbacks#5748

Merged
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:i18n-fixes
Mar 28, 2022
Merged

[EuiI18n] Fixed EuiContext.i18n's mappingFunc not being called for EuiI18n with multiple tokens and function callbacks#5748
cee-chen merged 5 commits intoelastic:mainfrom
cee-chen:i18n-fixes

Conversation

@cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Mar 28, 2022

Summary

I noticed this while attempting to QA #5743 with Babelfish checked in local dev.

Screencaps

Multiple tokens

Before

After

Function interpolation

Before

After

Checklist

// @ts-ignore TypeScript complains that `DEFAULT` doesn't have a call signature but we verified `renderable` is a function
return renderable(values);
const rendered = renderable(values);
return (i18nMappingFunc && typeof rendered === 'string'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thompsongl You were totally right in #5743 (comment) about needing to check for a string type, the unit tests helped me confirm that it will error if the returned render is JSX.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5748/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Great catch, fix, and tests! ❤️

@cee-chen
Copy link
Contributor Author

Thanks y'all!

@cee-chen cee-chen merged commit c162a15 into elastic:main Mar 28, 2022
@cee-chen cee-chen deleted the i18n-fixes branch March 28, 2022 19:55
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