Re: [DISCUSSION] Multilingual PHP
| From: | Yasuo Ohgaki | Date: | Thu, 02 May 2019 22:07:23 +0000 |
| Subject: | Re: [DISCUSSION] Multilingual PHP | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105573@lists.php.net to get a copy of this message | ||
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
>
> <?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,