-
Notifications
You must be signed in to change notification settings - Fork 824
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
RFC Replace Zend_Locale with new i18n backend #6194
Comments
I think within the "Date formatting" requirements, we need to list a couple of sub-requirements:
For "Number formatting":
And for message translation, any new solution we choose should also support the following new feature:
I don't think there's much value in a full wrapper (the API surface is huge) - it's an extension supported by the PHP project itself, so creating an abstraction layer in order to minimise risk of third party deprecations seems overkill. In the short term, we should pass through existing But by adding another half a dozen methods to our existing
According to Google Analytics on silverstripe.org, about 30% of our visitors have a browser locale other than Requiring Other projects requiring Projects not requiring it: Drupal, Typo3, Concrete5, ModX, Moodle, OctoberCMS, Yii, Wordpress, Laravel (unsurprisingly since it's just a framework without UI)
We could deprecate the YAML translation format (and provide a conversion script) if it limits our choices too much. Transifex can deal with lots of other formats: http://docs.transifex.com/formats/, incl. XLIFF and PHP. We'll also need to check if the locale list in |
BTW, Drupal originally supported This is a bit different to our situation though: We're already using ISO formats, so the challenge is the other way around. |
Yes zend used RFC 2822 format date, which I had originally documented, but I decided to keep an open mind about format specificity. :) I'd be happy to add this back into the requirements. Based on what you've stated above, even allowing i18n to be disabled with a lack of a core dependency could be a pretty huge cost. Perhaps it's worth looking at an i18n custom option that negated the need to use php-intl (or at least approximated the functionality adequately in its absence). This is most definitely the highest maintenance of the options. |
The problem is that there may not be an author in certain cases (e.g. anonymous front-end users). The i18n system should really be able to infer standard formats without requiring human interaction. |
Is Do you collect information about the installed PHP extensions with the SilverStripe installer? If yes, it might be useful to see what the coverage of php intl is like? As for the preferred solution: I'd stick with Zend. Reasoning: Easier migration and it seems to cover the requirements. |
It would be good to understand whether php-intl is provided by default in the current stable versions of:
|
I was initially nervous about requiring php-intl as a dependency for all users but if half of users are likely to benefit from l10n, making it optional adds substantial cost, and php-intl is widespread amongst current installs, maybe it's okay to require. |
So,
I'm assuming that CentOS is similar. |
It does (through
I think for self-hosting we should be fine. For managed hosting, it's a bit harder to find out about support. I've looked at a few common hosting providers. Basically anybody claiming to host Magento needs to have php-intl, which should make it pretty common already. Also anyone allowing SSH access and/or CPanel should have it.
So we'll be trailblazers with this decision, but it seems doable. Worth putting a vote to the community? Phrased as "if we require php-intl, we can spend more resources on other features" |
OK so on the basis of all that my recommendation is that we require php-intl, and refactor our current Zend code just to use the php-intl library directly, at least for date/time/currency/number stuff. I don't have a clear idea of what we would need between php-intl and transifex to to our string replacements, but I think that the current family of |
There should be a way to customise localised data anyway, Zend 1 libraries were great for customisation. There is new development in Symfony: Simplify access to CLDR/ICU data |
I've updated this RFC to limit discussion scope to date/number localisation, and leave the related message translation discussion to it's own RFC: #6221 |
So it sounds like |
OK the results of the vote on #6207 are that we shouldn't have too much of a problem adding php-intl as a requirement for ss4. |
I'm wondering how you solved the text direction (LTR or RTL) issue. I don't see a solution in pnp-intl or symfony. |
@craigh I just coded a list of RTL locales in a config var in i18n. It's not perfect, but the list is short enough we can just list them. |
👍 |
can this be closed? |
We will close this RFC with the above being merged. |
PR at #6607 |
Created a follow up issue with #6626 |
See #5359
dev list post: https://groups.google.com/forum/#!topic/silverstripe-dev/BVgFrxb7ISw
Introduction
Currently SilverStripe framework relies on Zend framework v1 for several core localisation features. This includes the below Zend components:
The libraries these features are built on top of are several years out of date and require upgrading.
Exclusions
Note that the following other zend components remain a dependency of other parts of the CMS and are not covered by this RFC, even if these may be affected by the outcome of the decided direction.
Zend_TranslateMoved to RFC Replace or upgrade Zend_Translate #6221Solution Requirements:
The chosen solution will need to either provide the below functionality, or have added on top of the core library to meet the necessary functionality:
PHP INTL Dependency
Many modern i18n Solutions require the php intl library. Currently SilverStripe does not, although evading this as a requirement in future releases will limit our options.
Symfony currently provides a polyfill for intl https://github.com/symfony/polyfill.
Our options are:
Investigation of symfony's polyfill implementation seems extremely incomplete, or implemented at a very shallow level only. E.g. stubs containing
MethodNotImplementedException
and hard-coded support foren
locale only. Supporting or offering an incomplete solution in my mind is worse than no solution at all.I recommend option 4, as it allows us to build a full i18n backend that will operate with all necessary features, but provides room for the community to develop a custom backend (or backends) to support environments without php-intl.
Example i18n Options:
Given that there are a huge number of possible i18n solution libraries, below is a non-exhaustive list of examples of solutions that could be considered.
1. Write i18n wrapper over php-intl
If we rely on php-intl, we could simplify the current i18n class into a wrapper over this extension. This solution would be the most work and be the hardest to maintain, but would allow us to minimise our dependencies.
Separate components would need to be built for string / number manipulation, as well as message translations, with the bulk of the work in implementing a translation mechanism which is compatible with our current yml translation system.
Dependencies:
2. Zf2-i18n
Currently at version 2.7, which is also the current version for this component in the current zend-framework 3.0. The good news is that this implies the 2.x branch of this module will be supported within the immediate future.
This is probably the least disruptive upgrade as zendframework/zend-i18n replaces Zend_Translate API. This provides standard formatters for Currency, Date, Number, and Pluralisation.
Documentation at:
Dependencies: (1.5mb)
4. Cakephp intl
Mainly a message formatting library, but has some php-intl wrappers around date and number formatting. Documentation http://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html
Dependencies: (600k)
Conclusion
Based on the solution we choose to pursue, it appears that there may be as many as two separate components; One for message localisation, and another for formatting of strings / date / time / numbers.
The desired response to this RFC should be in the form of either suggestion of an unnamed solution, or support for one of the prior named solutions.
The desired outcome of this RFC will be a mutually agreed upon technical direction, and a next step to explore. This will include our desired response to php-intl as a requirement.
Related
Tasks
Notes:
The text was updated successfully, but these errors were encountered: