Skip to content

Conversation

@nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

An idea that came when reviewing symfony/symfony-docs#12440

@ro0NL
Copy link
Contributor

ro0NL commented Oct 8, 2019

unicode defines a start/middle/end part: https://github.com/unicode-org/icu/blob/fd123bf023882f07bfacf51c39111be2f946d8f8/icu4c/source/data/locales/en.txt#L2008-L2019

this was on my list to investigate :) not sure it fits String component, as i was already skeptical about $glue->join($strings) for an API.

ultimately i want to format list values in ICU translation files, but the spec format is missing still :( https://github.com/tc39/proposal-intl-list-format

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Oct 8, 2019

@ro0NL I'm not trying to solve 100% of the problem but the most common that we've all been solving again and again. TC39 is another level of complexity (same reasoning about title(true): it's not linguistically universal, yet it's common enough to deserve being supported out of the box.)

Copy link
Contributor

@ro0NL ro0NL left a comment

Choose a reason for hiding this comment

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

anyway, i think this feature is fine for non-localized stuff either way 👍

@gharlan
Copy link
Contributor

gharlan commented Oct 9, 2019

What do you think about making the method static, like in Java: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-

For me, it is a kind of named special constructor for a string (and not a method for doing something with the glue string).
$str = UnicodeString::join($array, $glue, $lastGlue);

@nicolas-grekas
Copy link
Member Author

I think it would make the method harder to discover.

@stof
Copy link
Member

stof commented Oct 11, 2019

I'm not even sure this should belong to a String component, as it is more about dealing with arrays...

@nicolas-grekas
Copy link
Member Author

@stof Python has it. That's a serious enough precedent to me.

nicolas-grekas added a commit that referenced this pull request Oct 11, 2019
…as-grekas)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[String] add $lastGlue argument to join() methods

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

An idea that came when reviewing symfony/symfony-docs#12440

Commits
-------

714d629 [String] add $lastGlue argument to join() methods
@nicolas-grekas nicolas-grekas merged commit 714d629 into symfony:master Oct 11, 2019
@nicolas-grekas nicolas-grekas deleted the s-join branch October 11, 2019 13:35
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.

8 participants