# [DISCUSSION] Multilingual PHP

- Thread: https://externals.io/message/105253
- Original archive: https://news-web.php.net/php.internals/105253
- Started by Michael Morris on 2019-04-11T20:32:08+00:00
- Messages: 12
- 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

---

## #105253 — Michael Morris — 2019-04-11T20:32:08+00:00

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

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

<?php[マニュアル]

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.

---

## #105254 — Benjamin Morel — 2019-04-11T21:16:43+00:00

URL: https://externals.io/message/105253#105254

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




> 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
>
> <?php[マニュアル]
>
> 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 — Stanislav Malyshev — 2019-04-11T21:35:31+00:00

URL: https://externals.io/message/105253#105255

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

---

## #105256 — Bruce Weirdan — 2019-04-11T21:36:36+00:00

URL: https://externals.io/message/105253#105256

On Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel <benjamin.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 — Walter Parker — 2019-04-11T21:57:31+00:00

URL: https://externals.io/message/105253#105257

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 Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel <benjamin.morel@gmail.com>
> wrote:
>
> > […]
>
> 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 — Derick Rethans — 2019-04-11T22:09:50+00:00

URL: https://externals.io/message/105253#105258

> 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 — Bruce Weirdan — 2019-04-11T22:25:38+00:00

URL: https://externals.io/message/105253#105259

>
> 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

---

## #105260 — johannes@schlueters.de — 2019-04-11T22:26:29+00:00

URL: https://externals.io/message/105253#105260

Hi,


> 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 — Michael Morris — 2019-04-12T13:10:24+00:00

URL: https://externals.io/message/105253#105261

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 — Yasuo Ohgaki — 2019-05-02T22:07:23+00:00

URL: https://externals.io/message/105253#105573

> 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
>
> <?php[マニュアル]
>
> 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
<?php

$変数あ = 1234;
$変数い = 4567;

function 変数ダンプ(...$変数) {
  var_dump(...$変数);
}

変数ダンプ($変数あ, $変数い);


[yohgaki@dev ~]$ php -n t.php
int(1234)
int(4567)


So if anyone would like to have translated function names/etc, may do

<?php
require_once 'translated_func_name_ja.php';

// USE translated function names/etc

Although this requires runtime overheads, i.e. additional function call,
it would be better to leave users if they prefer native names or not. IMO.

I'm not sure if bison/re2c supports UTF-8. If it does, translating keywords
such as "if"/"class",
should be easy task. It removes barrier for non English speaker kids and
would be good as
forked project.


Regards,

---

## #105575 — Legale Legage — 2019-05-02T22:23:55+00:00

URL: https://externals.io/message/105253#105575

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 <benjamin.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
>
>
> 
>
> > […]
> https://www.wired.com/story/coding-is-for-everyoneas-long-as-you-speak-english/
> > […]
> the
> > […]
> language
> > […]
> head
> > […]
> Wired
> > […]
> their
> > […]

---

## #105576 — Er Galvao Abbott — 2019-05-02T22:31:50+00:00

URL: https://externals.io/message/105253#105576

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 Fri, Apr 12, 2019 at 12:17 AM Benjamin Morel <benjamin.morel@gmail.com>
> wrote:
>
> > […]
> 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.
