Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Translation] Added intl message formatter. #20007

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

Closed
wants to merge 1 commit into from

Conversation

aitboudad
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

Related to #18314

),
array(
'4,560 monkeys on 123 trees make 37.073 monkeys per tree',
'{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point in MessageFormatter abstraction if at the end you are coupled with specific implementation?

@Koc
Copy link
Contributor

Koc commented Sep 21, 2016

ref #10671, #10152, #6009

@fabpot
Copy link
Member

fabpot commented Sep 30, 2016

This only makes sense if we support the plurals as well.

@MatTheCat
Copy link
Contributor

This seems abandoned, does this mean we'll have to add an IntlMessageFormatter ourselves in order to use \MessageFormatter?

@nicolas-grekas
Copy link
Member

Moving to 4.1. Rebase on master needed, where PHP 7.1 features can be used btw.

@nicolas-grekas nicolas-grekas modified the milestones: 3.4, 4.1 Oct 8, 2017
@stof
Copy link
Member

stof commented Mar 9, 2018

The issue with the PR in its current state is that it creates a community split: as soon as you configure Symfony to use the intl formatter in your project, it becomes incompatible with all bundles written using the default formatter (and this includes translations shipped in the core for validation errors). This makes it impossible to use it in a gradual way.

@sstok
Copy link
Contributor

sstok commented Mar 11, 2018

@stof indeed 😞 I guess the only way to resolve this is adding an extra argument to the trans method (CustomTransformerTranslatorInterface with an overwrite of trans() to add an additional argument) 🤔 not the nicest way but at least it would make is possible to use the new Transformer without breaking BC.

And we can't add a flag to a translation file because YAML and PHP for example use a hash at the root level, plus making @format_transformer a special key feels a bit strange 😛 and would still require a proper solution for XLIFF.

@stof
Copy link
Member

stof commented Mar 19, 2018

@sstok requiring code using the translations to provide the formatter to use to format this message looks really weird, because it puts this info in the wrong place. The template doing a translation calls has no idea which formatter implementation the original file was written for.

This only makes sense if we support the plurals as well.

The ICU message format supports pluralization based on any parameter (and on multiple ones), as this is one of the available features inside the string. We don't need a specific transChoice feature in this case (which is an API limited to a single integer being the pluralization source)

@aitboudad
Copy link
Contributor Author

I think grouping messages by formatter would solve the issue, something like domain part.
I haven't yet to time to investigate on it, so if anyone interested on it would be welcomed 😄

@MatTheCat
Copy link
Contributor

Couldn't we make intl mandatory for Symfony 5? 😌

@fabpot
Copy link
Member

fabpot commented Jun 10, 2018

Closing in favor of #27399

@fabpot fabpot closed this Jun 10, 2018
@aitboudad aitboudad deleted the intl-formatter branch June 10, 2018 10:07
fabpot added a commit that referenced this pull request Sep 4, 2018
…, Nyholm)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Translation] Added intl message formatter.

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | replaces #20007
| License       | MIT
| Doc PR        |

This PR will replace #20007 and continue the work from the original author.

I've have tried to address all comments made in the original PR.

Commits
-------

2a90931 cs
fb30c77 Be more specific with what exception we catch
b1aa004 Only use the default translator if intl extension is loaded
f88153f Updates according to feedback
597a15d Use FallbackFormatter instead of support for multiple formatters
2aa7181 Fixes according to feedback
a325a44 Allow config for different domain specific formatters
b43fe21 Add support for multiple formatters
c2b3dc0 [Translation] Added intl message formatter.
19e8e69 use error
940d440 Make it a warning
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants