-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Intl] Refactored Locale component into two new components Icu and Intl #7386
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
Conversation
The circular dependency between |
And IMO, |
And some of the utils used to build the ICU data should be moved to Icu instead of being in Intl IMO |
@stof The circular dependency can't be removed. One component cannot be installed without the other (by design). The separation into separate components has a single purpose: separate versioning.
Equally, the symfony/intl component has one master branch while the symfony/icu repository has seven (40-master, 42-master etc.). To make maintenance easier, every piece of code that is not directly related to the ICU data of a specific version is contained in the Intl component. That's why the scripts are there and not in the Icu component. I'm ok for changing |
@bschussek But circular dependencies may cause some weird issues when solving. Btw, why naming the branch |
@stof If you don't have lib-ICU installed, it doesn't matter which symfony/icu version is installed. It will not be used but be simply ignored. I wasn't aware that I could simply name the branch |
@bschussek It will matter unless the stub implementation is able to load the ResourceBundle for any ICU version (including future versions) which is not the case as the format of the ICU file is not BC (which is what you are trying to fix for the case where the real Intl is used). The stub implementation of ResourceBundle will be tied to an ICU version. For the branch name, yes. This is exactly how the And btw, the |
@stof Again, the files in the Icu component are completely ignored if the intl extension is not available. That means:
That means that if the intl extension is not available, the Intl component emulates a specific intl version (50.1.0 right now). We don't even have to load the Icu component in this case, but there is currently no way to avoid this with Composer. |
@stof Have a closer look ;) |
@bschussek Having a close look is not as easy as usually when github refuses to display the diff for the PR :) Btw, it looks like the bin script are trying to use an inexistant autoload file: https://github.com/bschussek/symfony/blob/c3b98a066e3ca80874701d8c299f726c676ef621/src/Symfony/Component/Intl/Resources/bin/icu-version.php#L15 |
Anybody else wondering, you can look at the source view here: https://github.com/bschussek/symfony/tree/intl/src/Symfony/Component/Intl @stof I added the autoload file now. |
@bschussek Sure we can see the source there, but not easily the difference compared to master... |
@stof that's not really @bschussek 's fault, is it? |
@bendavies noit is not. It is simply because the intl data are lots of files |
@stof i am aware of why github won't show the diff. |
@bendavies Seeing the patch does not allow commenting on it to do the PR review. @bschussek in CurrencyBundleInterface (and the other bundle interfaces), the phpdoc mentions |
I would suggest to open another PR with the binary changes and keep it off from this PR to ease reviewing. |
Why are the separate branches necessary? Can't the component ship all binary data? |
@asm89 the goal is precisely to avoid having all the different versions together and having to choose the right ones (which is why the Locale component has a rule to ignore the other versions currently) |
I built all the ICU branches now. Only some glitches in the documentation are missing now, unless you have further feedback. And does anybody have a clue what causes the failing tests on Travis? |
@schmittjoh What's the way to go to ignore the leftover Scrutinizer errors? |
You can use the delete button on the comment (top right), then they are On Sat, Mar 16, 2013 at 11:58 AM, Bernhard Schussek <
|
Apparently I cannot when I'm logged in. Do I need admin rights on symfony/symfony? |
Forget it, it works now. Sorry. |
Oh, ResourceBundle? I think this will confuse developers when use with symfony's bundle system. |
There is one major stumble stone left before this PR can be merged. We want to load only symfony/icu versions that are compatible with the ICU library bundled with the local PHP installation. This was achieved by:
This way
Apparently though composer cannot handle inverse ranges in the conflict clause (e.g. @Seldaek Do you see any solution? |
To clarify, symfony/icu is not needed when lib-ICU is not present. With the current design it would be installed anyway. |
@bschussek IMO if things get too crazy the best option is to always enforce it's installation, and skip using it if the ICU version is unusable, or never require it but throw an exception when it's missing but ICU is avail, or solve it via documentation somehow. |
…event the stub class tests from failing
…h the changed Icu component versioning
@bschussek I think the problem of the lock file I mentioned before is still true, that if you run update with a given ICU version, then you can't install from that lock file on another machine with different ICU, if the symfony/icu package requires that specific ICU version. In a way that's good because it means people will notice it early, and that's better than doing it in a logged warning IMO, but that's probably going to cause some support load. |
@Seldaek I see, thank you. What would people need to do in this case? Is it possible to update the lock file entry for symfony/icu by first calling
and then
? |
Well, Another hack could be to require explicitly the symfony/icu that your
Which will make all symfony/icu installable, but that should be done What are the consequences of running symfony/icu on an incorrect ICU data? |
I just tried to reproduce this but failed. When not having a vendor directory, this command also installed the newest version of other packages and overwrote the versions in my lock file.
Potentially fatal errors. We are using the class I would prefer a solution where people don't have to worry about ICU at all. Which version of symfony/icu is installed is irrelevant for the dev, he just wants a working one. Is it possible to exclude symfony/icu from the lock file? |
It would be nice if developer could somehow override the icu data version. e.g the developer knows that the icu data files for 5.0 are compatible with the 4.8 library it's server has installed. |
I will do more research on which ICU versions exactly are compatible in this regard. |
… symfony/icu with the ICU version installed on the system
I've done some research and testing and reduced the number of symfony/icu branches to three:
The format of the .res files was changed once with ICU 4.4 and is not BC with 4.0 and 4.2. A problem with deployment can now only occur if:
Solution: Add the following configuration to your project's composer.json:
This problem should be solved now. I will add this information to the documentation of the Intl component. |
Another potential problem might be when
Again, the solution is adding the following lines to the project's composer.json:
|
I don't know what the current situation is, but it sounds to me like this PR is just adding complexity. I never had problems with ICU and I don't know if that's because I was lucky or not. What's this PR solving exactly? And if there are only two data set formats isn't it possible to ship a single package with both formats included in their latest available versions? I understand that there is a waste of space, but is it that big? |
@Seldaek The PR solves three issues:
Considering waste of space, the 1.1.x branch of the symfony/intl component has more than 19M, while the 1.2.x branch (used by the majority of users) has only 9M due to an optimized data format in later ICU versions. Even the 9M add considerable waiting time when installing composer dependencies. Combining both branches into one package would unnecessarily increase this time even more. |
I improved the inline documentation and finished the symfony-docs PR now. Please review this PR again, it is otherwise ready to be merged. |
This PR was merged into the master branch. Discussion ---------- [Intl] Refactored Locale component into two new components Icu and Intl | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #5279 | License | MIT | Doc PR | symfony/symfony-docs#2312 The Intl component is now a simple drop-in replacement layer for the C intl extension. Install it via Composer and have it available automatically if the intl extension is not available. Additionally, the component ships data from the ICU library which can be accessed through the methods: ```php use Symfony\Component\Intl\Intl; Intl::getCurrencyBundle()->... Intl::getLanguageBundle()->... Intl::getLocaleBundle()->... Intl::getRegionBundle()->... ``` If the intl extension is installed, Composer will install the ICU data for the ICU version in the intl extension. If the intl extension is not installed, Composer will use stub ICU data for the latest ICU version (see `Intl::getStubIcuVersion()`). See the [README](/bschussek/symfony/blob/intl/src/Symfony/Component/Intl/README.md) for more information. Todo: - [x] finish the Intl README file - [x] update the Icu README file - [x] update the documentation - [x] make parameter `$locale` optional (default to `\Locale::getDefault()`) in resource bundle methods - [x] remove `(Icu)?Version::compare` calls in the tests - [x] solve deployment problem when trying to install incompatible symfony/icu version listed in composer.lock Create the following branches in the [Icu component](https://github.com/symfony/Icu): - [x] 1.0.x - [x] 1.1.x - [x] 1.2.x Commits ------- 9118b4a [Locale] Removed "Stub" prefixes in Intl component b4cccfd [Intl] Removed "Stub" prefix from stub classes 60f31d1 [Intl] Improved inline documentation c2d37e6 [Intl] Improved error messages in the build scripts 1249f01 [Intl] Added scripts to test the compatibility of various versions of symfony/icu with the ICU version installed on the system 9dbafd7 [Intl] Split update-stubs.php script into two scripts to function with the changed Icu component versioning e2c11cb [Intl] Added a check for the ICU data version to IntlTestHelper to prevent the stub class tests from failing 427d24a [Intl] Outsourced bundle reader creation to Icu component 0160fd5 [Intl] Moved stub data to Icu component 1.0.x dbca3b7 [Intl] Added empty directory needed for the tests a717ce9 [Intl] Removed ICU version comparisons from the tests 5d17de5 [Intl] Fixed version comparisons in the transformation rules 470927d [Intl] Improved build scripts aceb20d [Form] Improved tests to use the IntlTestHelper class 3dd75ff [Locale] Improved tests to use the IntlTestHelper class 03b78b0 [Validator] Improved tests to use the IntlTestHelper class 9d9c389 [Intl] Simplified tests c55c4a2 [Intl] Only the StubNumberFormatterTest requires stub data 17a480b [Intl] Added IntlTestHelper class for convenience 1dcdcd3 [Locale] Fixed failing tests f6b75b9 [Intl] Changed composer.json to disallow future versions of the Icu component 080c880 [Intl] Bumped the stub version to 50.1.2 dd2d013 [Intl] Improved the bundle compilation process f47e60a [Intl] Fixed small bugs in the resource bundle transformation 467cc93 [Intl] Fixed various problems in the resource compilation process 4a5c453 [Intl] Moved the content of the README file to symfony/symfony-docs 9899de7 [Intl] Updated the README bfec58a [Intl] Fixed flawed PHPDoc 21323ba [Intl] Updated the README file 209a9cb [Validator] Adapted to latest Intl changes f2a0aec [Form] Adapted to latest Intl changes 0f6277f [Locale] Adapted to latest Intl changes 2cd1be8 [Intl] Made the $locale parameter optional in the bundle interfaces b9e9cb2 [Intl] Added autoload.php which was ignored by .gitignore 838798f [Intl] Removed method IntlTestCase::skipIfInsufficientIcuVersion() dde1d34 [Intl] Changed Intl::getIcuVersion() to return the stub version if the intl extension is not loaded 99f6f8a [Form] Fixed failing tests 5d0b849 Fixed PHPDoc b60866c [Intl] Changed Intl::getStubIcuVersion() to Intl::getIcuStubVersion() b902b6b [Locale] Added default locale 01d0ee8 [Validator] Changed component to use the Intl component 0c1fe39 [Form] Changed component to use the Intl component 5917a2e [Intl] Refactored Locale component into two new components Icu and Intl
The Intl component is now a simple drop-in replacement layer for the C intl extension. Install it via Composer and have it available automatically if the intl extension is not available.
Additionally, the component ships data from the ICU library which can be accessed through the methods:
If the intl extension is installed, Composer will install the ICU data for the ICU version in the intl extension. If the intl extension is not installed, Composer will use stub ICU data for the latest ICU version (see
Intl::getStubIcuVersion()
).See the README for more information.
Todo:
$locale
optional (default to\Locale::getDefault()
) in resource bundle methods(Icu)?Version::compare
calls in the testsCreate the following branches in the Icu component: