You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.
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
The idea here is the Translator accept a Dictionary, which accept a Locale :
In code, this looks like :
$locale = new Locale('fr_FR');
$dictionary = new Dictionary($locale, $this->ci->locator);
$translator = new Translator($dictionary);
The locale contains all the info about the locale itself, including all metadata loaded from the config file. Speaking of the config file, by default, the file is loaded from locale://fr_FR/locale.yaml path, but it can be overwritten by the constructor second argument.
The Dictionary returns the data for all available locale files, including the data from dependent locale.
Finally, the translator uses the array from the Dictionary, plus the info from the locale saved inside the Dictionary to provide the actual translation.
So switching the locale (userfrosting/UserFrosting#868) is simply a matter of providing a different Dictionary, based on a different Locale.
It also mean to generate a list of all available locales (userfrosting/UserFrosting#850) we don't need the whole translator. The UF config files can contains only a list of "available" locales
Everything is also constructed using Interfaces, so one could use their own Locale or Dictionary class. For example, a Locale could be loaded from the db, or the dictionary loaded from xml files.
Things left to do :
Make the Dictionary extends the Repository class
Move the Dictionary repository methods to an abstract class + add tests + extend the core one instead? (What to do with the $items?)
- Default yaml config now `locale.yaml`
- getDependentLocales now return an array of locales
- getDependentLocalesIndentifier added
- yaml now optional
- getDependentLocalesIndentifier can't return a null
The locale contains all the info about the locale itself, including all metadata loaded from the config file. Speaking of the config file, by default, the file is loaded from locale://fr_FR/locale.yaml path, but it can be overwritten by the constructor second argument.
Actually, the only issue is here. Right now, it assume all dependent locale uses that config file. Not sure if it can be done in another way...
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
None yet
1 participant
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 rewrite includes :
The idea here is the Translator accept a Dictionary, which accept a Locale :
In code, this looks like :
The locale contains all the info about the locale itself, including all metadata loaded from the config file. Speaking of the config file, by default, the file is loaded from
locale://fr_FR/locale.yaml
path, but it can be overwritten by the constructor second argument.The Dictionary returns the data for all available locale files, including the data from dependent locale.
Finally, the translator uses the array from the Dictionary, plus the info from the locale saved inside the Dictionary to provide the actual translation.
So switching the locale (userfrosting/UserFrosting#868) is simply a matter of providing a different Dictionary, based on a different Locale.
It also mean to generate a list of all available locales (userfrosting/UserFrosting#850) we don't need the whole translator. The UF config files can contains only a list of "available" locales
Everything is also constructed using Interfaces, so one could use their own
Locale
or Dictionary class. For example, a Locale could be loaded from the db, or the dictionary loaded from xml files.Things left to do :
$items
?)