-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FluentLanguageLoader::lang method #88
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This field was always the first loaded language or the fallback_language so this field contained redundant information.
This commit changes the internal structure of the FluentLanguageLoader into a wrapper that contains an internal structure which can be copied and replaced in a cheap way so that creating a copy of the loader is as cheap as possible.
I rebased this branch on the current |
@bikeshedder did you still want to proceed with this? |
I do prefer this implementation over the other one. It's much cleaner and makes it possible to pick the language using the regular |
kellpossible
pushed a commit
that referenced
this pull request
Jan 14, 2023
Adds a single new method lang. This methods allows creating a shallow copy of the FluentLanguageLoader which can than be used just like the original loader but with a different current language setting. That makes it possible to use the fl! macro without any changes and is a far more elegant implementation than adding multiple get_lang* methods as done in #84. Co-authored-by: Michael P. Jung <[email protected]>
Closed in favour of #100 |
kellpossible
added a commit
that referenced
this pull request
Jan 14, 2023
Re-implementation of #59 (a rebase and cleanup of #88) Adds a single new method lang. This methods allows creating a shallow copy of the FluentLanguageLoader which can than be used just like the original loader but with a different current language setting. That makes it possible to use the fl! macro without any changes and is a far more elegant implementation than adding multiple get_lang* methods as done in #84. Co-authored-by: Michael P. Jung <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is an alternative implementation for #59 and is based on the code from #84.
This PR adds a single new method:
This methods allows creating a shallow copy of the
FluentLanguageLoader
which can than be used just like the original loader but with a different current language setting. That makes it possible to use thefl!
macro without any changes and is a far more elegant implementation than adding multipleget_lang*
methods as done in #84.For a future change I'd like to remove the
RwLock
and change that to a builder pattern. e.g. while building the loader you can still access the bundles in a mutable way but once the build is complete the internal language config is locked in and can't be changed anymore. That would get rid of locking primitive which is there just because of theset_use_isolating
andwith_bundles_mut
methods.This PR doesn't change the public API so it is a non-breaking change just like the other PR.