[PHP-DEV][DISCUSSION] Multilingual PHP

  105253
April 11, 2019 20:32 tendoaki@gmail.com (Michael Morris)
Submitted to the floor is a Wired article from 2 days ago I came across

https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-speak-english/

The manual of PHP is translated into multiple languages - but what are the
development hurdles of the language itself being multilingual?

From what I understand of the compiler - maybe not that much.  The language
requires an opening tag, so we could hook into that like this example for
Japanese


    
  105254
April 11, 2019 21:16 benjamin.morel@gmail.com (Benjamin Morel)
The problem with this approach is that while it may become more readable
for the native speaker, it becomes pretty much impossible to read for the
rest of the world.
Having one single syntax for everyone allows all programmers in the world
to share code. I can't imagine a world where I'd find a library based on
Russian PHP on GitHub, that I can't contribute to or even understand (I
probably wouldn't use it).
English has the huge advantage to be quite simple to learn for basic
purposes, and it has a limited alphabet, composed only of ASCII letters.

I'm not a native English speaker but have never been bothered by keywords
being called IF and THEN, even when reading BASIC books as a child before
taking any English course at school.

This may be harder for people having a native language with a different
alphabet, though.

- Ben


On Thu, 11 Apr 2019 at 22:32, Michael Morris <tendoaki@gmail.com> wrote:

> Submitted to the floor is a Wired article from 2 days ago I came across > > > https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-speak-english/ > > The manual of PHP is translated into multiple languages - but what are the > development hurdles of the language itself being multilingual? > > From what I understand of the compiler - maybe not that much. The language > requires an opening tag, so we could hook into that like this example for > Japanese > > > A PHP opening tag with such a qualifier would change over all function > names and reserved words. Could these would be set on a per file basis? > > The php.ini file could set the default language, the .htaccess file could > also on per directory. > > I'll stop there cause I know there are problems I haven't thought of. And > I'm not going to argue the syntax I just kicked out from the top of my head > is the best either. > > But I think it's worth the effort to at least look into the problem. Wired > has a point - people learn to code faster when they are working with their > own language. One of the stated goals of PHP's design has been > accessibility so this seems to be appropriate. > > I yield the floor to those smarter and wiser than I. >
  105256
April 11, 2019 21:36 weirdan@gmail.com (Bruce Weirdan)
On Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel morel@gmail.com>
wrote:

> This may be harder for people having a native language with a different > alphabet, though. >
That's unlikely to be a problem. Even to get to the PHP manual you have to type `www.php.net` (or `google.com` if you want to google something), so it implies you have a way to enter latin characters. Keyboard layout switching is a problem solved decades ago. -- Best regards, Bruce Weirdan mailto: weirdan@gmail.com
  105257
April 11, 2019 21:57 walterp@gmail.com (Walter Parker)
I also am old enough to have used/remember using BASIC. I remember German
and Japanese friends that wrote in BASIC. It was interesting to see German
programs where all the keywords were in English and all the text was in
German. The Japanese was even more strange as the system had to switch
between the code pages for ASCII/LATIN and the one for the Japanese
Language.

Today to get something other an ASCII/LATIN, we would have to support
Unicode for source code. Does PHP currently work if Unicode is used for
identifiers?


Walter

On Thu, Apr 11, 2019 at 2:36 PM Bruce Weirdan <weirdan@gmail.com> wrote:

> On Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel morel@gmail.com> > wrote: > > > This may be harder for people having a native language with a different > > alphabet, though. > > > > That's unlikely to be a problem. Even to get to the PHP manual you have to > type `www.php.net` (or `google.com` if you want to google something), > so it implies you have a way to enter latin characters. Keyboard layout > switching is a problem solved decades ago. > > -- > Best regards, > Bruce Weirdan mailto: > weirdan@gmail.com >
-- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis
  105258
April 11, 2019 22:09 derick@php.net (Derick Rethans)
On Thu, 11 Apr 2019, Walter Parker wrote:

> I also am old enough to have used/remember using BASIC. I remember German > and Japanese friends that wrote in BASIC. It was interesting to see German > programs where all the keywords were in English and all the text was in > German. The Japanese was even more strange as the system had to switch > between the code pages for ASCII/LATIN and the one for the Japanese > Language. > > Today to get something other an ASCII/LATIN, we would have to support > Unicode for source code. Does PHP currently work if Unicode is used for > identifiers?
Yes. You can use UTF-8 for function names and variables (but please don't!). My favourite annoyance is using a non breaking space in function/method names ;-) cheers, Derick
  105259
April 11, 2019 22:25 weirdan@gmail.com (Bruce Weirdan)
On Fri, Apr 12, 2019 at 1:10 AM Derick Rethans <derick@php.net> wrote:
> > My favourite annoyance is using a non breaking space in > function/method names ;-)
"Better" yet, you can use characters that are different, but look the same as Latin chars e.g. CYRILLIC SMALL LETTER ES (U+0441) instead of (LATIN SMALL LETTER C U+0063). Incidentally these two chars also share the same physical button in English/Russian keyboard layouts, so it's a mistake easy to make and very hard to spot visually: https://3v4l.org/rjjU9 -- Best regards, Bruce Weirdan mailto:weirdan@gmail.com
  105576
May 2, 2019 22:31 galvao@galvao.eti.br (Er Galvao Abbott)
My two cents on this, since I teach beginner courses on a regular basis:

All languages - that I'm aware of - have English as their basis. As a 
matter of fact our industry as a whole have English as it's basis. I 
often tell my students: learn English. You'll eventually need it and it 
will provide you with a whole different view of all things as you'll 
understand their meaning. You may argue it's unfair or even cruel, but 
it is what it is.

So while I understand the reason behind this discussion - and am even 
sympathetic towards it - it seems to be "Working on a problem that's not 
really there". Aside from all this, wasn't this one of the downfalls of 
PHP6?

Er Galvão Abbott
Development, Consulting and Teaching
https://www.galvao.eti.br/ | galvao@galvao.eti.br
------------------------------------------------------------
Contributor and Evangelist, PHP <galvao@php.net>
Director, PHP Conference Brazil <galvao@phpconference.com.br>
Zend Framework Evangelist @ Roguewave Zend's ZTeam
Fedora Ambassador LATAM <galvao@fedoraproject.org>
Guest (Specialist) Post Graduation Professor
------------------------------------------------------------

On 4/11/19 6:36 PM, Bruce Weirdan wrote:
> On Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel morel@gmail.com> > wrote: > >> This may be harder for people having a native language with a different >> alphabet, though. >> > That's unlikely to be a problem. Even to get to the PHP manual you have to > type `www.php.net` (or `google.com` if you want to google something), > so it implies you have a way to enter latin characters. Keyboard layout > switching is a problem solved decades ago. >
  105575
May 2, 2019 22:23 legale.legale@gmail.com (Legale Legage)
We (Russians) have got such experience already. The language is 1S where
syntax is Cyrillic. This kind of syntax doesn’t like even Russian patriots.

чт, 11 апр. 2019 г., 23:16 Benjamin Morel morel@gmail.com>:

> The problem with this approach is that while it may become more readable > for the native speaker, it becomes pretty much impossible to read for the > rest of the world. > Having one single syntax for everyone allows all programmers in the world > to share code. I can't imagine a world where I'd find a library based on > Russian PHP on GitHub, that I can't contribute to or even understand (I > probably wouldn't use it). > English has the huge advantage to be quite simple to learn for basic > purposes, and it has a limited alphabet, composed only of ASCII letters. > > I'm not a native English speaker but have never been bothered by keywords > being called IF and THEN, even when reading BASIC books as a child before > taking any English course at school. > > This may be harder for people having a native language with a different > alphabet, though. > > - Ben > > > On Thu, 11 Apr 2019 at 22:32, Michael Morris <tendoaki@gmail.com> wrote: > > > Submitted to the floor is a Wired article from 2 days ago I came across > > > > > > > https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-speak-english/ > > > > The manual of PHP is translated into multiple languages - but what are > the > > development hurdles of the language itself being multilingual? > > > > From what I understand of the compiler - maybe not that much. The > language > > requires an opening tag, so we could hook into that like this example for > > Japanese > > > > > > > A PHP opening tag with such a qualifier would change over all function > > names and reserved words. Could these would be set on a per file basis? > > > > The php.ini file could set the default language, the .htaccess file could > > also on per directory. > > > > I'll stop there cause I know there are problems I haven't thought of. And > > I'm not going to argue the syntax I just kicked out from the top of my > head > > is the best either. > > > > But I think it's worth the effort to at least look into the problem. > Wired > > has a point - people learn to code faster when they are working with > their > > own language. One of the stated goals of PHP's design has been > > accessibility so this seems to be appropriate. > > > > I yield the floor to those smarter and wiser than I. > > >
  105255
April 11, 2019 21:35 smalyshev@gmail.com (Stanislav Malyshev)
Hi!

> I'll stop there cause I know there are problems I haven't thought of. And > I'm not going to argue the syntax I just kicked out from the top of my head > is the best either.
For better or for worse, English is the lingua franca of the internet technology. You can, of course, create a compiler which would understand keywords in other languages. This compiler will be used by 0.001% of the main language user base, code written with it will be inaccessible to any person who does not read that language, and communication between the users of different language-branches of the project would be virtually zero because they literally would have no common language. I don't think this would help anyone. Yes, basic knowledge of English is currently a requirement to engage with most technologies. Once you have mastered it, however, the whole technology world is available to you, at one-time investment. Fragmenting this world into tiny pieces, each with its own language, would not make these parts more accessible to each other.
> But I think it's worth the effort to at least look into the problem. Wired > has a point - people learn to code faster when they are working with their > own language. One of the stated goals of PHP's design has been
My native language is not English. Moreover, my first foreign language wasn't English either. I had no more trouble learning BASIC (yes, I am that old) or Pascal than I had learning programming languages based on my native tongue. The only difference is that the former translated pretty well into other languages I encountered when I progressed with my learning, while the latter did not, it was an isolated island not connected to anything else. -- Stas Malyshev smalyshev@gmail.com
  105260
April 11, 2019 22:26 johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=)
Hi,

On Do, 2019-04-11 at 15:32 -0500, Michael Morris wrote:
> Submitted to the floor is a Wired article from 2 days ago I came > across > > https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-spea > k-english/ >
Oh, memories. Microsoft Office has (or had) localised macros. This lead to many problems since localisaton depends on language installed and macros from one don't work on the other ... I don't believe the language itself should be translated. This limits portability and there are just a few keywords. If somebody wants to create localised libraries they can of course do .... An area I would find interesting is error messages. To a little degree we already have them localized: $ php -r 'setlocale(LC_ALL, "de_DE");fopen("/etc/passwd", "w");' PHP Warning:  fopen(/etc/passwd): failed to open stream: Keine Berechtigung in Command line code on line 1 Expanding might be interesting, but it is not a trivial task, as this might make error reporting (also suppressed one, i.e. deprecation warnings) slower and it is a big translation and maintenance work and has impact on support (I myself run my machines typically in English so I can Google error messages and receive better results or can grep the source for the origin) johannes
  105261
April 12, 2019 13:10 tendoaki@gmail.com (Michael Morris)
The replies so far have been excellent and I do appreciate the time given
to write them. Being a lazy one-language American (I tried to learn Spanish
but I've forgotten most of what I learned out of lack of use) I'm not
familiar with the obstacles to learning English beyond "gittin rid my
accint" when I was real little.

Several of you brought up a counterpoint Wired hadn't considered - that
having a common language facilitates cooperation around the globe. Some
large projects like Drupal, WordPress, and PHP itself couldn't be
undertaken without a common tongue.

A colleague of mine at word pointed out that there are preprocessors out
there such as antlr that can translate the language of a file into the
tokens the compiler will recognize. It seems an adequate solution, but I
don't know for sure.

Still, an interesting discussion overall. Thanks.
  105573
May 2, 2019 22:07 yohgaki@ohgaki.net (Yasuo Ohgaki)
On Fri, Apr 12, 2019 at 5:32 AM Michael Morris <tendoaki@gmail.com> wrote:

> Submitted to the floor is a Wired article from 2 days ago I came across > > > https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-speak-english/ > > The manual of PHP is translated into multiple languages - but what are the > development hurdles of the language itself being multilingual? > > From what I understand of the compiler - maybe not that much. The language > requires an opening tag, so we could hook into that like this example for > Japanese > > > A PHP opening tag with such a qualifier would change over all function > names and reserved words. Could these would be set on a per file basis? >
Interesting idea. This may be good for kids to learn programming language. PHP's parser is compatible with UTF-8, so code like this works. [yohgaki@dev ~]$ cat t.php yohgaki@dev ~]$ php -n t.php int(1234) int(4567) So if anyone would like to have translated function names/etc, may do