Re: PHP extension 'gettext' doesn't work?


Hiroaki Ukaji <dt3snow.w@...>
 

Hi.
Thanks a lot for your detailed checks and comments.

Could you include your sample PHP code?
Could you try with the latest build pack? That would rule out any issues
that have been already addressed.
Yes, I'll show my sample code and its results. Please see the following.
So, I take it "hello-world" should be replaced with a localized version?
Yes, I think it should be replaced the other word written in
`message.po` file.
It is true that PHP extension 'gettext' is being installed correctly,
but perhaps it seemed that 'gettext' function doesn't work well.


********** my sample source code **********
URL: https://github.com/hiroakiukaji/php-gettext-test

$ tree
.
├── index.php
└── locale
└── ja_JP.UTF-8
└── LC_MESSAGES
├── messages.mo
└── messages.po


$ vi index.php
<?php

$lang = "ja_JP.UTF-8";
$domain = "messages";

setlocale(LC_ALL, $lang);
bindtextdomain($domain, "./locale/");
textdomain($domain);

// message
echo _("hello world");


$ vi locale/ja_JP.UTF-8/LC_MESSAGES/messages.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL(a)ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-29 09:47+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL(a)ADDRESS>\n"
"Language-Team: LANGUAGE <LL(a)li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: index.php:7
msgid "hello world"
msgstr "konnnichiwa sekai"
********************

When we operate the above codes in my local machine, we get following
result.

********** result with my local machine (apache2+php5.5.29 on
Ubuntu14.04)**********
$ curl 127.0.0.1:80
konnnichiwa sekai
********************

In my local environment, the message "hello world" is translated into
japanese sentence, "konnnichiwa sekai".



The results on cloud foundry with 'latest' buildpack is as follows.
(php-buildpack v4.1.4 / cf-release v211 / bosh-lite #552dc68696 / cf-cli
v6.12.0)

********** full output of `cf push` (latest buildpack) **********
$ cf push php-get-test-v4.1.4 -b
https://github.com/cloudfoundry/php-buildpack
Creating app php-get-test-v4.1.4 in org ukaji / space default as ukaji...
OK

Creating route php-get-test-v414.10.244.0.34.xip.io...
OK

Binding php-get-test-v414.10.244.0.34.xip.io to php-get-test-v4.1.4...
OK

Uploading php-get-test-v4.1.4...
Uploading app files from: /home/ukaji/php-gettext-test
Uploading 2.4K, 8 files
Done uploading
OK

Starting app php-get-test-v4.1.4 in org ukaji / space default as ukaji...
-----> Downloaded app package (4.0K)
Cloning into '/tmp/buildpacks/php-buildpack'...
Submodule 'compile-extensions'
(https://github.com/cloudfoundry/compile-extensions) registered for path
'compile-extensions'
Cloning into 'compile-extensions'...
Submodule path 'compile-extensions': checked out
'450ef697e1ea234add05121fbeb5d05b056133c6'
-------> Buildpack version 4.1.4
Installing HTTPD
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/httpd/httpd-2.4.16-linux-x64.tgz]
to [/tmp]
Installing PHP
PHP 5.5.29
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/php/php-5.5.29-linux-x64-1442441030.tgz]
to [/tmp]
Finished: [2015-10-01 06:09:34.369789]
-----> Uploading droplet (41M)

1 of 1 instances running

App started


OK

App php-get-test-v4.1.4 was started using this command `$HOME/.bp/bin/start`

Showing health and status for app php-get-test-v4.1.4 in org ukaji / space
default as ukaji...
OK

requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: php-get-test-v414.10.244.0.34.xip.io
last uploaded: Thu Oct 1 06:08:49 UTC 2015
stack: cflinuxfs2
buildpack: https://github.com/cloudfoundry/php-buildpack

state since cpu memory disk
details
#0 running 2015-10-01 03:09:48 PM 0.0% 53.6M of 256M 0 of 1G
********************

********** result (latest buildpack) **********
$ curl php-get-test-v414.10.244.0.34.xip.io
hello world
********************

********** `cf logs` when I access a page (latest buildpack) **********
2015-10-01T15:12:19.33+0900 [RTR/0] OUT
php-get-test-v414.10.244.0.34.xip.io - [01/10/2015:06:12:19 +0000] "GET /
HTTP/1.1" 200 0 11 "-" "curl/7.35.0" 10.0.2.15:42716
x_forwarded_for:"192.168.50.1, 10.0.2.15"
vcap_request_id:1ae938d2-0d2c-45b7-4bd5-cfbbccb721e3
response_time:0.007400870 app_id:917e3e17-a77e-4b67-8776-bd0f938132f5
2015-10-01T15:12:19.35+0900 [App/0] OUT 06:12:19 httpd | 192.168.50.1
- - [01/Oct/2015:06:12:19 +0000] "GET / HTTP/1.1" 200 11
vcap_request_id=1ae938d2-0d2c-45b7-4bd5-cfbbccb721e3 peer_addr=10.0.2.15
********************

The results on cloud foundry with 'v211 default' buildpack is as follows.
(php-buildpack v3.2.1 / cf-release v211 / bosh-lite #552dc68696 / cf-cli
v6.12.0)

********** full output of `cf push` (cf v211 default buildpack) **********
$ cf push php-get-test-v3.2.1
Creating app php-get-test-v3.2.1 in org ukaji / space default as ukaji...
OK

Creating route php-get-test-v321.10.244.0.34.xip.io...
OK

Binding php-get-test-v321.10.244.0.34.xip.io to php-get-test-v3.2.1...
OK

Uploading php-get-test-v3.2.1...
Uploading app files from: /home/ukaji/php-gettext-test
Uploading 2.4K, 8 files
Done uploading
OK

Starting app php-get-test-v3.2.1 in org ukaji / space default as ukaji...
-----> Downloaded app package (4.0K)
-------> Buildpack version 3.2.1
Installing HTTPD
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 1534k 100 1534k 0 0 340M 0 --:--:-- --:--:-- --:--:--
340M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 14682 100 14682 0 0 106M 0 --:--:-- --:--:-- --:--:--
106M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_unixd-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 19969 100 19969 0 0 264M 0 --:--:-- --:--:-- --:--:--
264M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_setenvif-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 137k 100 137k 0 0 243M 0 --:--:-- --:--:-- --:--:--
243M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_proxy-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 16787 100 16787 0 0 181M 0 --:--:-- --:--:-- --:--:--
181M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_dir-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 20550 100 20550 0 0 222M 0 --:--:-- --:--:-- --:--:--
222M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_reqtimeout-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 42000 100 42000 0 0 90.0M 0 --:--:-- --:--:-- --:--:--
90.0M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_log_config-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 28927 100 28927 0 0 125M 0 --:--:-- --:--:-- --:--:--
125M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_authz_core-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 25276 100 25276 0 0 68.0M 0 --:--:-- --:--:-- --:--:--
68.0M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_mime-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 31561 100 31561 0 0 136M 0 --:--:-- --:--:-- --:--:--
136M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_proxy_fcgi-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 17805 100 17805 0 0 95.9M 0 --:--:-- --:--:-- --:--:--
95.9M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_remoteip-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 13323 100 13323 0 0 98.4M 0 --:--:-- --:--:-- --:--:--
98.4M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_env-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 72297 100 72297 0 0 325M 0 --:--:-- --:--:-- --:--:--
325M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_mpm_event-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 82878 100 82878 0 0 367M 0 --:--:-- --:--:-- --:--:--
367M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_rewrite-2.4.12.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 16145 100 16145 0 0 112M 0 --:--:-- --:--:-- --:--:--
112M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/httpd/2.4.12/httpd-mod_authz_host-2.4.12.tar.gz]
to [/tmp]
Installing PHP
PHP 5.5.23
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 5000k 100 5000k 0 0 490M 0 --:--:-- --:--:-- --:--:--
490M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/php/5.5.23/php-5.5.23.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 8640k 100 8640k 0 0 549M 0 --:--:-- --:--:-- --:--:--
549M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/php/5.5.23/php-fpm-5.5.23.tar.gz]
to [/tmp]
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left
Speed
100 18857 100 18857 0 0 224M 0 --:--:-- --:--:-- --:--:--
224M
Downloaded
[https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/php/5.5.23/php-gettext-5.5.23.tar.gz]
to [/tmp]
Finished: [2015-10-01 06:00:02.620608]
-----> Uploading droplet (16M)

1 of 1 instances running

App started


OK

App php-get-test-v3.2.1 was started using this command `$HOME/.bp/bin/start`

Showing health and status for app php-get-test-v3.2.1 in org ukaji / space
default as ukaji...
OK

requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: php-get-test-v321.10.244.0.34.xip.io
last uploaded: Thu Oct 1 05:59:53 UTC 2015
stack: cflinuxfs2
buildpack: PHP

state since cpu memory disk
details
#0 running 2015-10-01 03:00:12 PM 0.0% 26.7M of 256M 0 of 1G
********************

********** result (cf v211 default buildpack) **********
$ curl php-get-test-v321.10.244.0.34.xip.io
hello world
********************

********** `cf logs` when I access a page (cf v211 default buildpack)
**********
2015-10-01T15:05:31.87+0900 [RTR/0] OUT
php-get-test-v321.10.244.0.34.xip.io - [01/10/2015:06:05:31 +0000] "GET /
HTTP/1.1" 200 0 11 "-" "curl/7.35.0" 10.0.2.15:38404
x_forwarded_for:"192.168.50.1, 10.0.2.15"
vcap_request_id:426677e4-e17f-4e0e-5142-75700cd9a33b
response_time:0.003993564 app_id:471f624e-fe67-458e-b788-f131aa271650
2015-10-01T15:05:31.88+0900 [App/0] OUT 06:05:31 httpd | 192.168.50.1
- - [01/Oct/2015:06:05:31 +0000] "GET / HTTP/1.1" 200 11
vcap_request_id=426677e4-e17f-4e0e-5142-75700cd9a33b peer_addr=10.0.2.15
********************

Thanks.

Hiroaki UKAJI



--
View this message in context: http://cf-dev.70369.x6.nabble.com/cf-dev-PHP-extension-gettext-doesn-t-work-tp1984p2027.html
Sent from the CF Dev mailing list archive at Nabble.com.

Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.