Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

'setLocaleMessage' / 'mergeLocaleMessage' doesn't work if 'warnHtmlInMessage' is set to 'error' #789

Closed
vovkss opened this issue Mar 2, 2020 · 3 comments · Fixed by #817
Labels
help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request Type: Bug Bug or Bug fixes

Comments

@vovkss
Copy link

vovkss commented Mar 2, 2020

vue & vue-i18n version

vue version: 2.6.11
vue-i18n version: 8.15.4

Reproduction Link

https://jsfiddle.net/vovkss/4p5y86rn/

Steps to reproduce

Set warnHtmlInMessage: true.

Call setLocaleMessage or mergeLocaleMessage to change messages for any locale.
It doesn't matter whether messages were already set for the locale or not.

The new messages must NOT contain HTML.

What is Expected?

Messages are changed for the target locale.

What is actually happening?

setLocaleMessage or mergeLocaleMessage have no effect.

@vovkss
Copy link
Author

vovkss commented Mar 2, 2020

The reason is the following line of code for setLocaleMessage:

https://github.com/kazupon/vue-i18n/blob/v8.x/src/index.js#L606

and the following line for mergeLocaleMessage:

https://github.com/kazupon/vue-i18n/blob/v8.x/src/index.js#L614

@kazupon kazupon added Type: Bug Bug or Bug fixes help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request labels Mar 2, 2020
@aym3nb
Copy link
Contributor

aym3nb commented Mar 20, 2020

Hey @vovkss
Can I grab this?
Also, since we expect the messages to be changed anyway, what's the point of having an error flag for warnHtmlInMessage?

@vovkss
Copy link
Author

vovkss commented Mar 22, 2020

Hey @vovkss
Can I grab this?
Also, since we expect the messages to be changed anyway, what's the point of having an error flag for warnHtmlInMessage?

Sure, I guess you can :)

According to the docs, 'warnHtmlInMessage' applies to dynamically loaded messages:

setLocaleMessage( locale, message )
...
If you set warn or error in the warnHtmlInMessage property, when this method is executed, it will check if HTML formatting is used for locale message.

aym3nb added a commit to aym3nb/vue-i18n that referenced this issue Mar 22, 2020
aym3nb added a commit to aym3nb/vue-i18n that referenced this issue Mar 22, 2020
kazupon pushed a commit that referenced this issue Mar 22, 2020
…arnHtmlInMessage' is set to 'error' (#817)

* build(deps): [security] bump handlebars from 4.1.1 to 4.5.3 (#757)

Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.1 to 4.5.3. **This update includes a security fix.**
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](handlebars-lang/handlebars.js@v4.1.1...v4.5.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* 🐛 #789 setLocaleMessage & mergeLocaleMessage doesn't work if warnHtmlInMessage is set to error

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed Status: PR Welcome Welcome to Pull Request Type: Bug Bug or Bug fixes
Projects
None yet
3 participants