Fixed failure to apply a default language after a request with specified language #5
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.
Description:
This pull request addresses the issue where the application, after a request with a specified language, fails to revert to a default language when the subsequent request does not specify a language. The current behavior retains the previous language instead of falling back to a default language, eg. the one set in
initOptions.lng
.Changes Made:
Code Modification:
Updated the logic in
onBeforeHandle
; If a language is not detected and the newuseLngAsDefault
option is true, it falls back to the default language specified ininitOptions.lng
.New Option:
Introduced a new option
useLngAsDefault
(defaults totrue
) to control whether the application should use the default language when a language is not specified/detected in a request.Test Cases:
useLngAsDefault: false
) works as intended.Documentation:
useLngAsDefault
.Thank you for reviewing this pull request!