feat: add a new option fallbackRootWithEmptyString #1441
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new option
fallbackRootWithEmptyString
. This option decides a i18n message should fallback to root or not if it's a empty string.Currently, the fallback root check logic is like this:
This means that: in the case that the
val
is an empty string(''), it will also fallback to root. This implementation is different from the one in version 9.x(in i18n 9.x, the empty string will not trigger fallback root). Besides that, this implementation may make it difficult if the user want to bypass the fallback operations of some value.This PR introduces a new option
fallbackRootWithEmptyString
whose default value istrue
. It means the default logic of fallback root is still like this :This means the PR is not a breaking change: by default, the fallback root logic will work in the existing logic.
When setting the
fallbackRootWithEmptyString
to befalse
m the fallback root logic will become like this:This means the emptr string('') will not trigger fallback root.
Besides that, I didn't add this option in the
api.md
, cause I want to hear your ideas about this new option first. :) @kazupon