# intl naming

- Thread: https://externals.io/message/36775
- Original archive: https://news-web.php.net/php.internals/36775
- Started by Stanislav Malyshev on 2008-04-03T04:58:24+00:00
- Messages: 44
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/36775.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #36775 — Stanislav Malyshev — 2008-04-03T04:58:24+00:00

URL: https://externals.io/message/36775#36775

Hi!

I wanted to ask the people here for opinions on the subject of functions 
naming in pecl/intl (hopefully soon to be ext/intl ;) module. Current 
state can be seen at http://docs.php.net/manual/en/book.intl.php

First, a bit of background.
Intl extension project was created with the purpose to bring 
internationalization capabilities of the ICU library to PHP 5, 
specifically 5.2.x and 5.3.x branches. We felt that as PHP gets more and 
more enterprise adoption, it needs to start supporting internationalized 
development much sooner than PHP 6 roadmap would allow us to. Thus, the 
goals of the project were chosen as follows:
1. Provide dual OO/procedural API for all functions
2. Provide same PHP API for both PHP 5 and PHP 6, to allow easy 
migration in the future
3. Keep same codebase in 5.x versions and keep codebases between 5 and 6 
as close as possible
4. Have separate functional modules for each functionality piece (number 
formatter, locale handling, collator, normalization, etc.) with intend 
to add more modules as we go, while keeping single extension as an 
umbrella for them.

As a consequence, we arrived at the naming scheme we have now in 
pecl/intl, i.e. classes named as NumberFormatter, MessageFormatter, 
DateFormatter, Collator, etc. and functions named as numfmt_*, msgfmt_*, 
collator_*, datefmt_*. The latter were chosed in accordance to the 
guidelines stated at http://www.php.net/reST/php-src/CODING_STANDARDS, 
saying:

If they [function names - SM] are part of a "parent set" of functions, 
that parent should be included in the user function name, and should be 
clearly related to the parent program or function family. This should be 
in the form of parent_*.

Recently, concerns were raised specifically about the name 
DateFormatter, which can potentially infringe on ext/date namespace, and 
in general about all the names. There were proposals to prefix all class 
and function names with Intl and intl_ respectively. While I feel that 
would make the API unnecessarily cluttered (since each module will have 
to keep its prefix anyway, we'd have stuff like 
intl_numfmt_parse_currency which IMO looks much uglier than 
numfmt_parse_currency, same goes for IntlCollator vs. Collator, etc.)
However, technically it is possible to do such change, and I believe if 
it has to be done it has to be done now, when we have first phase of the 
development feature-complete and ready (up to bugfixes here and there) 
to announce the module as 1.0 version for everybody to use.

So, I propose people to consider all the above and the following options:
1. Leave it as is.
Pro: we have it now and it works, and it looks nice.
Contra: see above

2. Rename only problematic one - DateFormatter to IntlDateFormatter
Pro: minimal change, nice names stay and can be used in PHP 6 API too.
Contra: one piece starts with Intl, others don't - API looks weird as a 
whole

3. Rename all classes to Intl* while leaving functions as is
Pro: All classes in the extension look the same, functions still have 
nice names
Contra: All classes get ugly names, and they are going to stay in PHP 6 
where those will be recommended system classes (so not Locale but 
IntlLocale, not Collator but IntlCollator).

4. Rename both classes and functions.
Pro: All API looks the same, purists are happy
Contra: API looks ugly, too many prefixes for functions.

So, please comment. If you have more ideas on the topic, please feel 
welcome to propose. We want to make this decision ASAP, so that we could 
move forward with the extension release.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36776 — Lester Caine — 2008-04-03T06:04:16+00:00

URL: https://externals.io/message/36775#36776 · In reply to: #36775

Stanislav Malyshev wrote:
> Hi!
> 
> I wanted to ask the people here for opinions on the subject of functions 
> naming in pecl/intl (hopefully soon to be ext/intl ;) module. Current 
> state can be seen at http://docs.php.net/manual/en/book.intl.php

I suppose the main question here is the simple one.
Will PHP6 be integrally - unicode?

Personally I WANT a clean character set free base to work from and that is 
what I was under the impression that PHP6 was going to provide. If the core is 
running unicode ( and I see no logical reason why it should run anything else 
- use PHP5 for an 'ascii' based version ) then why are we discussing 
separating out functions which are part of that core.

The core objects should properly handle unicode, so why have DUPLICATE 
functions such as Date and DateFormatter at all? Number and possibly Currency 
should also exist in the same way as Date? Collation is as much part of 
database handling as array, and upper and lower functions are not being moved 
TO intl so why should there be different handling of things.

I had expected to be running PHP6 in a clean UTF-8 mode by now, and that 
functions like localeconv would simply work. If that is not the intention for 
PHP6 then perhaps we need to start looking to a replacement of PHP6 already :(

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

---

## #36777 — Markus Fischer — 2008-04-03T06:30:49+00:00

URL: https://externals.io/message/36775#36777 · In reply to: #36775

Hi,

naming classes/function is really an important concern and I'm happy that such 
a thing gets a dedicated thread finally.

Stanislav Malyshev wrote:
> internationalization capabilities of the ICU library to PHP 5, 
> specifically 5.2.x and 5.3.x branches. We felt that as PHP gets more and 

Is there any chance this is not going to be available for 5.2?


Because if so, I would add another option to the naming suggestions below:

* finally *use* namespaces

Although I'm next to not at all involved in the current development, this was 
actually on my mind for a view days and I was thinking about writing to the list.

Especially with so many classes at once introduced  I think it would be a good 
idea to finally think about this too.


Personally, globbering the global namespace with such common names is 
irresponsible (but this has been discovered already).

Actually there are existing classes being named Locale, I fired a quick google 
code search:

http://www.google.com/codesearch?q=lang%3Aphp+class.*Locale&hl=en&btnG=Search+Code

Of course I've never heard of them myself, but it's really not hard to assume 
that such a class likely exists.

The same applies to the "Collator" class, see
http://www.google.com/codesearch?hl=en&lr=&q=lang%3Aphp+class.*Collator&btnG=Search

More example could probably be found but I think the two examples makes it 
clear that we need to namespace or prefix them. Of course I've never heard of 
and used any of those classes and I guess most internal developers here 
probably have neither, but that doesn't mean they aren't in use somewhere.

I understand that, as long as this has to be available for 5.2, namespaces are 
forever out because of BC. But if this could be pushed, I would really be happy.

Just to be clear, this is not some kind of bickering and especially not about 
ext/intl, but I'm trying to create a general awareness of problems we would 
run here in the future.

If namespaces aren't and option because waiting for 5.3 only is not viable, 
I'm for number four. Stop creating headaches with namespace/prefix-less 
introduction of new things.

> 4. Rename both classes and functions.
> Pro: All API looks the same, purists are happy
> Contra: API looks ugly, too many prefixes for functions.


thanks,
- Markus

---

## #36783 — John Carter -X johncart - PolicyApp Ltd@Cisco — 2008-04-03T08:49:29+00:00

URL: https://externals.io/message/36775#36783 · In reply to: #36775

Stanislav,

I like the look of the API. The naming convention appears logical, on
the question of internal class names existing in userland I'm sure
people will refer to the discussions around DateTime.

Many extensions appear to offer procedural style equivalents to the OOP
API, personally I think it would not missed if omitted - have you had
any specific requests for it?

On the API side have you considered throwing exceptions instead of
checking error statuses? Also would it not be useful to have the
DateFormatter optionally accept DateTime instances in addition to
strings?

Thanks,

John.

-----Original Message-----
From: Stanislav Malyshev [mailto:stas@zend.com] 
Sent: 03 April 2008 05:58
To: 'PHP Internals'
Subject: [PHP-DEV] intl naming

Hi!

I wanted to ask the people here for opinions on the subject of functions
naming in pecl/intl (hopefully soon to be ext/intl ;) module. Current
state can be seen at http://docs.php.net/manual/en/book.intl.php

First, a bit of background.
Intl extension project was created with the purpose to bring
internationalization capabilities of the ICU library to PHP 5,
specifically 5.2.x and 5.3.x branches. We felt that as PHP gets more and
more enterprise adoption, it needs to start supporting internationalized
development much sooner than PHP 6 roadmap would allow us to. Thus, the
goals of the project were chosen as follows:
1. Provide dual OO/procedural API for all functions 2. Provide same PHP
API for both PHP 5 and PHP 6, to allow easy migration in the future 3.
Keep same codebase in 5.x versions and keep codebases between 5 and 6 as
close as possible 4. Have separate functional modules for each
functionality piece (number formatter, locale handling, collator,
normalization, etc.) with intend to add more modules as we go, while
keeping single extension as an umbrella for them.

As a consequence, we arrived at the naming scheme we have now in
pecl/intl, i.e. classes named as NumberFormatter, MessageFormatter,
DateFormatter, Collator, etc. and functions named as numfmt_*, msgfmt_*,
collator_*, datefmt_*. The latter were chosed in accordance to the
guidelines stated at http://www.php.net/reST/php-src/CODING_STANDARDS,
saying:

If they [function names - SM] are part of a "parent set" of functions,
that parent should be included in the user function name, and should be
clearly related to the parent program or function family. This should be
in the form of parent_*.

Recently, concerns were raised specifically about the name
DateFormatter, which can potentially infringe on ext/date namespace, and
in general about all the names. There were proposals to prefix all class
and function names with Intl and intl_ respectively. While I feel that
would make the API unnecessarily cluttered (since each module will have
to keep its prefix anyway, we'd have stuff like
intl_numfmt_parse_currency which IMO looks much uglier than
numfmt_parse_currency, same goes for IntlCollator vs. Collator, etc.)
However, technically it is possible to do such change, and I believe if
it has to be done it has to be done now, when we have first phase of the
development feature-complete and ready (up to bugfixes here and there)
to announce the module as 1.0 version for everybody to use.

So, I propose people to consider all the above and the following
options:
1. Leave it as is.
Pro: we have it now and it works, and it looks nice.
Contra: see above

2. Rename only problematic one - DateFormatter to IntlDateFormatter
Pro: minimal change, nice names stay and can be used in PHP 6 API too.
Contra: one piece starts with Intl, others don't - API looks weird as a
whole

3. Rename all classes to Intl* while leaving functions as is
Pro: All classes in the extension look the same, functions still have
nice names
Contra: All classes get ugly names, and they are going to stay in PHP 6
where those will be recommended system classes (so not Locale but
IntlLocale, not Collator but IntlCollator).

4. Rename both classes and functions.
Pro: All API looks the same, purists are happy
Contra: API looks ugly, too many prefixes for functions.

So, please comment. If you have more ideas on the topic, please feel
welcome to propose. We want to make this decision ASAP, so that we could
move forward with the extension release.
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

--
 To unsubscribe,
visit: http://www.php.net/unsub.php

---

## #36785 — Stanislav Malyshev — 2008-04-03T22:57:40+00:00

URL: https://externals.io/message/36775#36785 · In reply to: #36776

Hi!

> I suppose the main question here is the simple one.
> Will PHP6 be integrally - unicode?

Sure, it will :)

> run anything else - use PHP5 for an 'ascii' based version ) then why are 
> we discussing separating out functions which are part of that core.

Because we need them much sooner than PHP 6 would be released. We need 
them yesterday.

> The core objects should properly handle unicode, so why have DUPLICATE 
> functions such as Date and DateFormatter at all? Number and possibly 

We don't duplicate them, we add them.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36786 — Stanislav Malyshev — 2008-04-03T22:59:35+00:00

URL: https://externals.io/message/36775#36786 · In reply to: #36777

Hi!

> Is there any chance this is not going to be available for 5.2?

No. One of the goals was to provide 5.2 support from the start, to 
enable large projects (read: no way switching to 5.3 soon after the 
release) to start using it ASAP.

> Because if so, I would add another option to the naming suggestions below:
> 
> * finally *use* namespaces

I'd love it, but unfortunately - see above.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36794 — Lester Caine — 2008-04-04T07:43:57+00:00

URL: https://externals.io/message/36775#36794 · In reply to: #36785

Stanislav Malyshev wrote:
> Hi!
> 
> > […]
> 
> Sure, it will :)
> 
> > […]
> 
> Because we need them much sooner than PHP 6 would be released. We need 
> them yesterday.

THAT I agree with - BUT WHAT IS STOPPING PHP6 being the solution. I can't see 
any reason that time is being wasted on yet another PHP5.X when that same 
effort could be directed to getting at least a stable beta of PHP6 out the door?

> > […]
> 
> We don't duplicate them, we add them.
intl itself is a duplication or rather creation of additional functions which 
SHOULD simply be provided by the core functions.

MessageFormatter simply duplicates and complicates a simple display of a 
message with embedded variables. If I ask for to output a string with 
variables in using a different locale then the DATE variables should simple 
display the correct format for that locale. I should not have to go through 
all the code and re-write the variables in some complex format so another 
package can then do the same job that the core system IS ALREADY DOING?

Collator is already required to process strtoupper and strtolower, so why 
should we need to decide if we can use them or we need to create a new object 
and get that to do the job.

PLEASE - what is stopping PHP6 becoming a platform that we can start working 
with today?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

---

## #36796 — Tex Texin — 2008-04-04T08:50:00+00:00

URL: https://externals.io/message/36775#36796 · In reply to: #36794

Lester asks:

THAT I agree with - BUT WHAT IS STOPPING PHP6 being the solution. I can't see any reason that time is being wasted on yet another PHP5.X when that same effort could be directed to getting at least a stable beta of PHP6 out the door?

Tex replies:

When we started this project nearly a year ago (earlier when I started lobbying Yahoo for resources for it) I naively imagined the project would be a few months. As PHP 6 was more than a year away and I suspected it would drift further into the future, it seemed like a good investment. We also considered that we wanted a solution that could be adopted immediately. PHP 6 being a major release would require more testing before deployment and likely also to have a few bugs. (No disrespect to the developers. It's a rule of thumb.)

The extension is near done, requires much less testing and as it is compatible with 5.2 is going to be very easy for people to test and deploy.
The tradeoff made sense.

When it comes down to it, we spent a few man-months and have a 5.2 solution and can deploy in 2008. 
The same few manmonths on 6 would not give a deployed solution in 2008, if for no other reason then the effort it will take to test a major release, but also because (I expected) php 6 would not be ready in 2008.

==============
Lester asks also:

MessageFormatter simply duplicates and complicates a simple display of a message with embedded variables. If I ask for to output a string with variables in using a different locale then the DATE variables should simple display the correct format for that locale. I should not have to go through all the code and re-write the variables in some complex format so another package can then do the same job that the core system IS ALREADY DOING?

Collator is already required to process strtoupper and strtolower, so why should we need to decide if we can use them or we need to create a new object and get that to do the job.

Tex replies:

I am not clear on what you are asking. It is expected that the string with embedded values is not substituted by a developer but by translators.
So for example, you could store the english string in a database table with a field for language and a field for the string and another field to identify the string.
A program could choose to retrieve a string by id and language and the string would be used with the formatter and program variables, to display the values correctly formatted for the locale in an appropriately translated string.

With respect to dates, there are simple and more complex forms. You can use the simple format. Also, note that even in one locale, you may want to influnce whether the date is a verbose long format or a shorter form. So the formatter offers options. The doc makes it seem very complex, but in practice it shouldn't be bad.

---

## #36804 — Derick Rethans — 2008-04-04T11:37:06+00:00

URL: https://externals.io/message/36775#36804 · In reply to: #36796

Tex,

please please quote properly, it is really hard to follow the conversion 
down below here. http://www.netmeister.org/news/learn2quote.html has 
some good information on this topic.

regards,
Derick




> Lester asks:
> 
> THAT I agree with - BUT WHAT IS STOPPING PHP6 being the solution. I can't see any reason that time is being wasted on yet another PHP5.X when that same effort could be directed to getting at least a stable beta of PHP6 out the door?
> 
> Tex replies:
> 
> When we started this project nearly a year ago (earlier when I started lobbying Yahoo for resources for it) I naively imagined the project would be a few months. As PHP 6 was more than a year away and I suspected it would drift further into the future, it seemed like a good investment. We also considered that we wanted a solution that could be adopted immediately. PHP 6 being a major release would require more testing before deployment and likely also to have a few bugs. (No disrespect to the developers. It's a rule of thumb.)
> 
> The extension is near done, requires much less testing and as it is compatible with 5.2 is going to be very easy for people to test and deploy.
> The tradeoff made sense.
> 
> When it comes down to it, we spent a few man-months and have a 5.2 solution and can deploy in 2008. 
> The same few manmonths on 6 would not give a deployed solution in 2008, if for no other reason then the effort it will take to test a major release, but also because (I expected) php 6 would not be ready in 2008.
> 
> ==============
> Lester asks also:
> 
> MessageFormatter simply duplicates and complicates a simple display of a message with embedded variables. If I ask for to output a string with variables in using a different locale then the DATE variables should simple display the correct format for that locale. I should not have to go through all the code and re-write the variables in some complex format so another package can then do the same job that the core system IS ALREADY DOING?
> 
> Collator is already required to process strtoupper and strtolower, so why should we need to decide if we can use them or we need to create a new object and get that to do the job.
> 
> Tex replies:
> 
> I am not clear on what you are asking. It is expected that the string with embedded values is not substituted by a developer but by translators.
> So for example, you could store the english string in a database table with a field for language and a field for the string and another field to identify the string.
> A program could choose to retrieve a string by id and language and the string would be used with the formatter and program variables, to display the values correctly formatted for the locale in an appropriately translated string.
> 
> With respect to dates, there are simple and more complex forms. You can use the simple format. Also, note that even in one locale, you may want to influnce whether the date is a verbose long format or a shorter form. So the formatter offers options. The doc makes it seem very complex, but in practice it shouldn't be bad.
> 
> 

-- 
Derick Rethans
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

---

## #36805 — Tex Texin — 2008-04-04T12:19:14+00:00

URL: https://externals.io/message/36775#36805 · In reply to: #36804

-----Original Message-----
From: Derick Rethans [mailto:derick@php.net] 
Sent: Friday, April 04, 2008 4:37 AM
To: Tex Texin
Cc: Lester Caine; PHP internals
Subject: RE: [PHP-DEV] intl naming

Tex,

please please quote properly, it is really hard to follow the conversion down below here. http://www.netmeister.org/news/learn2quote.html has some good information on this topic.

regards,
Derick


Derick, Please state what you object to. I looked at the article.
I attributed the text, I responded inline, I clipped the text to the piece I was responding to, blank line in between.
I could have used a > instead of a colon in the attribution... And perhaps a signal that I clipped.
Is that what bothers you?

The questions and answers look straightforward to me.








> Lester asks:
> 
> THAT I agree with - BUT WHAT IS STOPPING PHP6 being the solution. I can't see any reason that time is being wasted on yet another PHP5.X when that same effort could be directed to getting at least a stable beta of PHP6 out the door?
> 
> Tex replies:
> 
> When we started this project nearly a year ago (earlier when I started 
> lobbying Yahoo for resources for it) I naively imagined the project 
> would be a few months. As PHP 6 was more than a year away and I 
> suspected it would drift further into the future, it seemed like a 
> good investment. We also considered that we wanted a solution that 
> could be adopted immediately. PHP 6 being a major release would 
> require more testing before deployment and likely also to have a few 
> bugs. (No disrespect to the developers. It's a rule of thumb.)
> 
> The extension is near done, requires much less testing and as it is compatible with 5.2 is going to be very easy for people to test and deploy.
> The tradeoff made sense.
> 
> When it comes down to it, we spent a few man-months and have a 5.2 solution and can deploy in 2008. 
> The same few manmonths on 6 would not give a deployed solution in 2008, if for no other reason then the effort it will take to test a major release, but also because (I expected) php 6 would not be ready in 2008.
> 
> ==============
> Lester asks also:
> 
> MessageFormatter simply duplicates and complicates a simple display of a message with embedded variables. If I ask for to output a string with variables in using a different locale then the DATE variables should simple display the correct format for that locale. I should not have to go through all the code and re-write the variables in some complex format so another package can then do the same job that the core system IS ALREADY DOING?
> 
> Collator is already required to process strtoupper and strtolower, so why should we need to decide if we can use them or we need to create a new object and get that to do the job.
> 
> Tex replies:
> 
> I am not clear on what you are asking. It is expected that the string with embedded values is not substituted by a developer but by translators.
> So for example, you could store the english string in a database table with a field for language and a field for the string and another field to identify the string.
> A program could choose to retrieve a string by id and language and the string would be used with the formatter and program variables, to display the values correctly formatted for the locale in an appropriately translated string.
> 
> With respect to dates, there are simple and more complex forms. You can use the simple format. Also, note that even in one locale, you may want to influnce whether the date is a verbose long format or a shorter form. So the formatter offers options. The doc makes it seem very complex, but in practice it shouldn't be bad.
> 
> 

--
Derick Rethans
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

---

## #36806 — Stanislav Malyshev — 2008-04-04T18:47:53+00:00

URL: https://externals.io/message/36775#36806 · In reply to: #36794

Hi!

> THAT I agree with - BUT WHAT IS STOPPING PHP6 being the solution. I 
> can't see any reason that time is being wasted on yet another PHP5.X 
> when that same effort could be directed to getting at least a stable 
> beta of PHP6 out the door?

I'm sorry you don't see the reason, but we do. The reason being, as I 
said, that it is needed by people in 5.x timeframe, not 6.x timeframe.

> MessageFormatter simply duplicates and complicates a simple display of a 
> message with embedded variables. If I ask for to output a string with 

No it doesn't. It supports ICU functionality in with message formatting 
(BTW backed by a number of ICU tools).

> Collator is already required to process strtoupper and strtolower, so 
> why should we need to decide if we can use them or we need to create a 
> new object and get that to do the job.

For PHP 6 Collator will be integrated with the rest of core 
functionality. And BTW, you don't need collator for strtoupper, you need 
it for sort. Collation and case conversion/folding is not the same.

> PLEASE - what is stopping PHP6 becoming a platform that we can start 
> working with today?

There's a lot of work still for integrating intl extension with PHP 6 
(and PHP 5 too), please tell me when you are ready to start and I'll 
describe the tasks for you.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36807 — Pierre Joye — 2008-04-04T19:07:25+00:00

URL: https://externals.io/message/36775#36807 · In reply to: #36806

Hi Stan,



> > […]
> working with today?
> > […]
>
>  There's a lot of work still for integrating intl extension with PHP 6 (and
> PHP 5 too), please tell me when you are ready to start and I'll describe the
> tasks for you.

A small reply to this post (I'm still testing intl and writing my
feedback reply), more specifically to this answer.

Yes, please tell us your "long" term plan/roadmap/todo, what is the
remaining work in intl and unicode, in php6 (from a ICU integration
point of view). We have a wonderful tool to document such tasks very
efficiently at http://wiki.php.net. Doing so may help you to do not be
"out of resources" and to get contributions from the PHP community
directly.

Another question is still not answered, I read a couple of times "we
decided" or similar answers. As it is obvious that things have to be
decided, I did not find any public reference about any kind of
discussions so I suppose that it was done off list or in your private
list. Secondly I find amazing to reject requests because you already
decided the right way to do it. If it is so, why do you ask for our
opinions?

Cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36808 — Stanislav Malyshev — 2008-04-04T19:27:50+00:00

URL: https://externals.io/message/36775#36808 · In reply to: #36807

Hi!

> Yes, please tell us your "long" term plan/roadmap/todo, what is the
> remaining work in intl and unicode, in php6 (from a ICU integration
> point of view). We have a wonderful tool to document such tasks very
> efficiently at http://wiki.php.net. Doing so may help you to do not be
> "out of resources" and to get contributions from the PHP community
> directly.

It's a good idea, but I want to deal with this release first. I will do 
it, but a bit later.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36809 — Pierre Joye — 2008-04-04T19:33:18+00:00

URL: https://externals.io/message/36775#36809 · In reply to: #36808

> Hi!
>
>
>
> > […]
>
>  It's a good idea, but I want to deal with this release first. I will do it,
> but a bit later.

I really have hard time to understand the "everything after 1.0.0".
That makes little sense to me. As I can understand the commercial
needs behind it, I can't think of going stable while there is still
issues to be solved prior this kind a release. Especially as BC won't
be broken afterwards.

It is also amazing to systematically ignore my comments about your off
list discussions (same in Andi's reply).

Cheers.
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36810 — Andi Gutmans — 2008-04-04T21:59:17+00:00

URL: https://externals.io/message/36775#36810 · In reply to: #36809

> -----Original Message-----
> From: Pierre Joye [mailto:pierre.php@gmail.com]
> Sent: Friday, April 04, 2008 12:33 PM
> To: Stas Malyshev
> Cc: Lester Caine; PHP internals
> Subject: Re: [PHP-DEV] intl naming
> 
> 
> It is also amazing to systematically ignore my comments about your off
> list discussions (same in Andi's reply).
> 

Actually I didn't. Go and read my answer from April 1st.

I'm hopping on a plane in a few hours and will be gone for most of the
next two weeks. Will be catching up on emails but not as regularly as
when I'm at work. I don't think we have to rehash the same things over
and over again (jump (not that I was in favor but I don't think we
should rehash it either), ext/intl in PHP 5.3, etc...). ext/intl
specifically has been around for quite a lot of time including
"documentation" (which many extension authors actually typically ignore
to begin with making it hard for the community to give feedback), etc...
As I said in my previous email ext/intl is mainly wrappers around ICU.
We don't need to boil the ocean. If there are naming concerns then let's
change those and move on...


Andi

---

## #36814 — dz@bitxtender.com — 2008-04-05T14:35:57+00:00

URL: https://externals.io/message/36775#36814 · In reply to: #36775

What about
a) an "ICU" prefix?
b) daring the leap and use namespaces, making it 5.3+ only (I know,  
that wasn't the plan, but maybe it would be a good idea)


David

--
David Zülke
dz@bitxtender.com
Tel: +49 (0)89 57 08 15 15
Fax: +49 (0)89 57 08 15 17
bitXtender GbR
Paul-Heyse-Straße 6
80336 München








Am 03.04.2008 um 06:58 schrieb Stanislav Malyshev:
> Hi!
>
> I wanted to ask the people here for opinions on the subject of  
> functions naming in pecl/intl (hopefully soon to be ext/intl ;)  
> module. Current state can be seen at http://docs.php.net/manual/en/book.intl.php
>
> First, a bit of background.
> Intl extension project was created with the purpose to bring  
> internationalization capabilities of the ICU library to PHP 5,  
> specifically 5.2.x and 5.3.x branches. We felt that as PHP gets more  
> and more enterprise adoption, it needs to start supporting  
> internationalized development much sooner than PHP 6 roadmap would  
> allow us to. Thus, the goals of the project were chosen as follows:
> 1. Provide dual OO/procedural API for all functions
> 2. Provide same PHP API for both PHP 5 and PHP 6, to allow easy  
> migration in the future
> 3. Keep same codebase in 5.x versions and keep codebases between 5  
> and 6 as close as possible
> 4. Have separate functional modules for each functionality piece  
> (number formatter, locale handling, collator, normalization, etc.)  
> with intend to add more modules as we go, while keeping single  
> extension as an umbrella for them.
>
> As a consequence, we arrived at the naming scheme we have now in  
> pecl/intl, i.e. classes named as NumberFormatter, MessageFormatter,  
> DateFormatter, Collator, etc. and functions named as numfmt_*,  
> msgfmt_*, collator_*, datefmt_*. The latter were chosed in  
> accordance to the guidelines stated at http://www.php.net/reST/php-src/CODING_STANDARDS 
> , saying:
>
> If they [function names - SM] are part of a "parent set" of  
> functions, that parent should be included in the user function name,  
> and should be clearly related to the parent program or function  
> family. This should be in the form of parent_*.
>
> Recently, concerns were raised specifically about the name  
> DateFormatter, which can potentially infringe on ext/date namespace,  
> and in general about all the names. There were proposals to prefix  
> all class and function names with Intl and intl_ respectively. While  
> I feel that would make the API unnecessarily cluttered (since each  
> module will have to keep its prefix anyway, we'd have stuff like  
> intl_numfmt_parse_currency which IMO looks much uglier than  
> numfmt_parse_currency, same goes for IntlCollator vs. Collator, etc.)
> However, technically it is possible to do such change, and I believe  
> if it has to be done it has to be done now, when we have first phase  
> of the development feature-complete and ready (up to bugfixes here  
> and there) to announce the module as 1.0 version for everybody to use.
>
> So, I propose people to consider all the above and the following  
> options:
> 1. Leave it as is.
> Pro: we have it now and it works, and it looks nice.
> Contra: see above
>
> 2. Rename only problematic one - DateFormatter to IntlDateFormatter
> Pro: minimal change, nice names stay and can be used in PHP 6 API too.
> Contra: one piece starts with Intl, others don't - API looks weird  
> as a whole
>
> 3. Rename all classes to Intl* while leaving functions as is
> Pro: All classes in the extension look the same, functions still  
> have nice names
> Contra: All classes get ugly names, and they are going to stay in  
> PHP 6 where those will be recommended system classes (so not Locale  
> but IntlLocale, not Collator but IntlCollator).
>
> 4. Rename both classes and functions.
> Pro: All API looks the same, purists are happy
> Contra: API looks ugly, too many prefixes for functions.
>
> So, please comment. If you have more ideas on the topic, please feel  
> welcome to propose. We want to make this decision ASAP, so that we  
> could move forward with the extension release.
> -- 
> Stanislav Malyshev, Zend Software Architect
> stas@zend.com   http://www.zend.com/
> (408)253-8829   MSN: stas@zend.com

---

## #36826 — Stanislav Malyshev — 2008-04-07T00:23:58+00:00

URL: https://externals.io/message/36775#36826 · In reply to: #36814

Hi!

> What about
> a) an "ICU" prefix?

I don't think it's better than intl_, having disadvantage of referring 
to particular library rather than function (like glibc_file_get_contents 
instead of file_get_contents).

> b) daring the leap and use namespaces, making it 5.3+ only (I know, that 
> wasn't the plan, but maybe it would be a good idea)

I'm afraid this is not an option.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36869 — Pierre Joye — 2008-04-08T12:41:59+00:00

URL: https://externals.io/message/36775#36869 · In reply to: #36810

Hi Stan, Andi and al!


> > […]
>
> > […]
>
>  Actually I didn't. Go and read my answer from April 1st.

does that count? =)

More seriously, it does not matter if you were in favor of this
private list or not, you should have refused it. But that's my
personal opinion and I agree with you, point made.

Now about ICU, I like its simplicity. There is a clear attempt to keep
the API readable and understable by the common users. Thanks for that!

I run some tests today based on my initial thoughts (which were based
only on the documentations). I even tried with a small application
here. I try to stay as constructive as possible in my comments,
suggestions or remarks. However, I know that my English or my tone may
give the impression that I try to impose my choice, that's not the
case :) please try to keep that in mind while reading.

I also apologize for the long text, I tried to keep it concise (and failed).

The numbering is only about helping possible replies or discussions.
They do not reflect any kind of priority or preferences.

1. Procedural API is somehow useless. It duplicates the complete API
   without adding any gain.

2. Multiple ways to create intl instances, I'm not sure we need both
   the factory and the constructor. It does not help the user to achieve
   his goal but create more possible confusions (and cause of errors/
   bugs). What was the idea behind ::create (if "new" has to be
   supported)

3. too many repetitive arguements, especially the locale.

   The ICU API solves this issue nicely using the current locale. It
   would be easier to work with the intl API if the same principle was
   used. Add a Locale::setDefault() and Locale::getDefault().

   The argument order for the constructors/factories should be change to
   allow that. The locale argument has to be optional (and moved as 2nd+
   argument).

   Arguments order may be confusing and hard to remember. However their
   names are self explaining as long as one is familiar with the ICU
   terminology. It would rock to allow array (key/pair) as
   input instead of many arguments.

4. Support of Date Object, they are the standard DateTime type in PHP.
   It has to be done prior 1.0.0 and 5.3.0, date and time are the most
   painful data to deal with in PHP. If intl and ext/date works hand in
   hand it will give PHP a big kick in the date/time.

   The advantages are obvious and many arguments and options can be
   taken from a given instance (timezone for example).

5. Error management is rather unintuitive. I can't imagine to have to
   check the error code after each call. Exceptions can greatly improve
   it.

   try {
   	$fmt = new NumberFormatter( 'fr_CH', ....);
   	echo $fmt->parse($num);
	$mydate = new DateFormatter( "fr_FR" , ...);
	$mydate->format($ts);
   } catch (Exception $e) {
   	....
   }

   I can't imagine the mess if I start to use the result of a method as
   arguments for other intl calls.

6. What's about a __toString implementation when possible. It may be
   handy to use an instance in the views (templates or whatever one
   uses as views) (). It can be done for all
   three formatters (number, message and date) classes.

   Prepare:
   $invoice_line_amount = new NumberFormatter( 'fr_CH',
NumberFormatter::DECIMAL );
   $invoice_line_amount->setValue($res);

   View:
   echo $invoice_line_amount;

Locale specific:
- Being able to parse, fetch and manage Locale IDs in a consistent and
  portable way would rock, the ISO3 related API is a must have prior
  1.0. It can be used from day #1 to normalize locale IDs format.

cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36877 — Stanislav Malyshev — 2008-04-08T17:04:39+00:00

URL: https://externals.io/message/36775#36877 · In reply to: #36869

Hi!

>    The ICU API solves this issue nicely using the current locale. It
>    would be easier to work with the intl API if the same principle was
>    used. Add a Locale::setDefault() and Locale::getDefault().

You can use default locale, of course, and Locale class already has 
these functions. http://docs.php.net/manual/en/class.locale.php

>    The argument order for the constructors/factories should be change to
>    allow that. The locale argument has to be optional (and moved as 2nd+
>    argument).

I'm afraid that wouldn't work since functions have variable number of 
arguments and we want consistent API across all modules.

>    Arguments order may be confusing and hard to remember. However their

Like "locale goes first"?

> 4. Support of Date Object, they are the standard DateTime type in PHP.

Planned to be done later - if anybody wants to contribute now, please 
do. It is indeed very important, we just don't have somebody to do it 
right now.

> 5. Error management is rather unintuitive. I can't imagine to have to
>    check the error code after each call. Exceptions can greatly improve

Like 99% people do with 99% functions in PHP? You must be really 
suffering not writing code in Java :)

> 6. What's about a __toString implementation when possible. It may be

If you can propose good toString - and especially if you have volunteer 
to implement it :) - why not? We didn't have good use for toString, but 
if you find one - welcome.

>    Prepare:
>    $invoice_line_amount = new NumberFormatter( 'fr_CH',
> NumberFormatter::DECIMAL );
>    $invoice_line_amount->setValue($res);
> 
>    View:
>    echo $invoice_line_amount;

We didn't purport to implement yet another MVC templating system here. 
We wrote ICU wrapper.

> Locale specific:
> - Being able to parse, fetch and manage Locale IDs in a consistent and
>   portable way would rock, the ISO3 related API is a must have prior
>   1.0. It can be used from day #1 to normalize locale IDs format.

Could you elaborate? I think our functions understand locales in 
standard formats, but maybe you mean something else.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36878 — Pierre Joye — 2008-04-08T18:40:26+00:00

URL: https://externals.io/message/36775#36878 · In reply to: #36877

Hi Stan,


> > […]
>
>  You can use default locale, of course, and Locale class already has these
> functions. http://docs.php.net/manual/en/class.locale.php

I did not find a way to do it in the manual or in the code. How do I
set in PHP? And how is it possible to use it as default for all
further calls (no matter which class/method)?

> > […]
>
>  I'm afraid that wouldn't work since functions have variable number of
> arguments and we want consistent API across all modules.

That's why I would prefer an array (as named arguments). The keys
(names) are easy to remember. You can even support both. I'm ready to
provide a patch to support array as input (with default values
support) if we agree on that.

> > […]
>
>  Like "locale goes first"?

The locale as 1st argument always looked weird to me when I was
writing my test code. The reason is certainly because of the default
locale not being set or used. As it is possible (if I understand you
correctly) I don't see why it has to be as first argument, one will
always has to pass it (NULL/"" or a valid locale id).

> > […]
>
>  Planned to be done later - if anybody wants to contribute now, please do.
> It is indeed very important, we just don't have somebody to do it right now.

If right now is not within days but within 2 weeks, I can try to do
it. But I first like to hear Derick's idea on the topic before. Please
let us know your thoughts (wiki?) about this topic, it will certainly
spare us some precious time.


> > […]
>
>  Like 99% people do with 99% functions in PHP? You must be really suffering
> not writing code in Java :)

Where did you get these numbers? For what I see nowadays, it is more a
high percentage with OO for everything but some basic helpers.
However, the point is not about OO or not OO but to do not duplicate
the API without any gain. Locale::foo() is as easy to write or read
than locale_foo().

> > […]
>
>  If you can propose good toString - and especially if you have volunteer to
> implement it :) - why not? We didn't have good use for toString, but if you
> find one - welcome.

I will think about it a bit more. But that will rock to have it :)

> > […]
>
>  We didn't purport to implement yet another MVC templating system here. We
> wrote ICU wrapper.

I was not clear, sorry. The goal is not to create a MVC but to allow
easy and user friendly usage without having to use intermediate string
variable or other custom objects.

> > […]
>
>  Could you elaborate? I think our functions understand locales in standard
> formats, but maybe you mean something else.

The idea is to have a way to get a code for a language, or to valid a
given code, etc. Many applications actually duplicate this list
internally, it would be very nice to be able to deal with the ICU
lists (display, validation, listings, etc.).

Cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36879 — Stanislav Malyshev — 2008-04-08T18:53:03+00:00

URL: https://externals.io/message/36775#36879 · In reply to: #36878

Hi!

> I did not find a way to do it in the manual or in the code. How do I
> set in PHP? And how is it possible to use it as default for all
> further calls (no matter which class/method)?

Locale::setDefault() and Locale::DEFAULT.

> That's why I would prefer an array (as named arguments). The keys

We aimed to create a wrapper for ICU, not reinvent how PHP language 
works. So we accept arguments the usual way - through function 
parameters, not through arrays.

> The locale as 1st argument always looked weird to me when I was
> writing my test code. The reason is certainly because of the default

I guess that's a matter of personal taste.

> If right now is not within days but within 2 weeks, I can try to do
> it. But I first like to hear Derick's idea on the topic before. Please
> let us know your thoughts (wiki?) about this topic, it will certainly
> spare us some precious time.

Well, the thoughts here are pretty simple - where date formatting 
functions accept timestamp and localtime array, they should accept 
DateTime object too. Also, there should be parse function returning 
DateTime, like one that returns timestamp. I think if you look in CVS in 
doc folder, early versions of date formatter API mention that.

> The idea is to have a way to get a code for a language, or to valid a
> given code, etc. Many applications actually duplicate this list
> internally, it would be very nice to be able to deal with the ICU
> lists (display, validation, listings, etc.).

You mean create API translating from language name in given locale to 
language code? I'm not sure ICU has this API. Locale class allows you to 
get components and display strings for the locales, but you have to have 
locale IDs first. There also are some matching functions in Locale, but 
I don't see any ICU functions allowing you to know IDs from external 
information, only to choose from set of IDs and enquire about ID.

As for validity, since locale mechanism has a bunch of fallbacks, I 
understand the validity concept is a bit blurred. I.e. you can have 
regexp to check all the -'s or _'s are in place but beyond that it's 
kind of hard to know what the question "is en_RU locale valid?" means.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36881 — Pierre Joye — 2008-04-08T19:09:19+00:00

URL: https://externals.io/message/36775#36881 · In reply to: #36879

Hi!



> > […]
>
>  Locale::setDefault() and Locale::DEFAULT.

Damned, I missed it four times :) It is not present in the synopsis
but in the methods list.

Then I really don't understand the current methods signature. The
locale should be optional and obivously not as first argument.

> > […]
>
>  We aimed to create a wrapper for ICU, not reinvent how PHP language works.
> So we accept arguments the usual way - through function parameters, not
> through arrays.

You may aim to create a thin wrapper around ICU, but we aim to create
the best possible i18n API. :-)

There is many API using this method when there is too many arguments,
when the risk of confusions is high.

About creating a wrapper, that's actually part of the solution to do
not create a thin wrapper but to add some "intelligence" in the
extension to ease its usage. It is even more important for APIs like
what intl try to do as it will be used by almost everyone out there.

> > […]
>
>  I guess that's a matter of personal taste.


No, that's a matter of being able to use a default locale without
passing `NULL` or an empty string. That's really bad practice to have an
optional argument as first argument.

> > […]
>
>  Well, the thoughts here are pretty simple - where date formatting functions
> accept timestamp and localtime array, they should accept DateTime object
> too. Also, there should be parse function returning DateTime, like one that
> returns timestamp. I think if you look in CVS in doc folder, early versions
> of date formatter API mention that.

Thanks for the hint, I will take a look at the history.

> > […]
>
>  You mean create API translating from language name in given locale to
> language code? I'm not sure ICU has this API. Locale class allows you to get
> components and display strings for the locales, but you have to have locale
> IDs first. There also are some matching functions in Locale, but I don't see
> any ICU functions allowing you to know IDs from external information, only
> to choose from set of IDs and enquire about ID.
>
>  As for validity, since locale mechanism has a bunch of fallbacks, I
> understand the validity concept is a bit blurred. I.e. you can have regexp
> to check all the -'s or _'s are in place but beyond that it's kind of hard
> to know what the question "is en_RU locale valid?" means.

It is amazingly handy to know that a locale given by the user (UI or a
developer using your library) is valid. What I like to have are
getCountry, getISO3* etc. I can provide a list and then a patch.


-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

## #36882 — Tomas Kuliavas — 2008-04-08T19:18:15+00:00

URL: https://externals.io/message/36775#36882 · In reply to: #36881

> > […]
>
> It is amazingly handy to know that a locale given by the user (UI or a
> developer using your library) is valid. What I like to have are
> getCountry, getISO3* etc. I can provide a list and then a patch.

I think locale validity detection does not work in PHP6
locale_set_default() too. Bug 42471.

-- 
Tomas

---

## #36883 — Stanislav Malyshev — 2008-04-08T19:35:17+00:00

URL: https://externals.io/message/36775#36883 · In reply to: #36881

Hi!

> It is amazingly handy to know that a locale given by the user (UI or a
> developer using your library) is valid. What I like to have are

What is "valid"? Database can have no exact match for locale string, but 
still have some data from fallbacks, etc.

> getCountry, getISO3* etc. I can provide a list and then a patch.

You have getRegion, but it looks like no ISO ones now.
-- 
Stanislav Malyshev, Zend Software Architect
stas@zend.com   http://www.zend.com/
(408)253-8829   MSN: stas@zend.com

---

## #36884 — Pierre Joye — 2008-04-08T19:43:19+00:00

URL: https://externals.io/message/36775#36884 · In reply to: #36883

re,


> > […]
>
>  What is "valid"? Database can have no exact match for locale string, but
> still have some data from fallbacks, etc.
>
> > […]
>
>  You have getRegion, but it looks like no ISO ones now.

The current one is somehow limited given what ICU provides. I know
that locale string are evil but it is the exact reason why we should
help our developers to use some more standard one, whenever it is
possible. Having the previously cited functions as well as getISO*,
getAvailableLocale, etc. will help.

Will you agree to extend the Locale API to provide more informations?

--
Pierre
http://blog.thepimp.net | http://www.libgd.org

---

Next page: https://externals.io/message/36775.md?page=2
