473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Get locales without shell access?

Rik
Hi all,

is there a in PHP to get the available locales without shellacces (i.e.
locale -a)?

Grtz,
--
Rik Wasmus
Oct 13 '06 #1
8 4671
Rik
Rik wrote:
is there a _way_ in PHP to get the available locales without shellacces?
:-)

Grtz,
--
Rik Wasmus
Oct 13 '06 #2
Rik wrote:
Hi all,

is there a in PHP to get the available locales without shellacces
(i.e. locale -a)?

Grtz,
Does this do anything for you? ->

<pre><?php passthru("locale -a"); ?></pre>

The <pre></preis just for the sake of formatting. Whether or not the
above code line will work, depends on the system configuration (ie. the
ability to run external commands may be disabled by the administrator).

If you want to assign this to an array, try using exec() with the
output parameter passed, like this:

<?php exec("locale -a",$output); ?>

In the above example, each element in the $output array contains a
locale (ie. a line from the command output).

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Oct 13 '06 #3
Rik
Kim André Akerĝ wrote:
Rik wrote:
>Hi all,

is there a in PHP to get the available locales without shellacces
(i.e. locale -a)?

Grtz,

Does this do anything for you? ->

<pre><?php passthru("locale -a"); ?></pre>

The <pre></preis just for the sake of formatting. Whether or not the
above code line will work, depends on the system configuration (ie.
the ability to run external commands may be disabled by the
administrator).
Well, that's the problem: I cannot start external programs. Here on my own
server it's no problem, but it's for a dynamic package that has to work on
a lot of different servers, where running an external program is often
blocked. Looping through hundreds of possibilities and checking for false
is a big pain in this case, but the only solution I've found so far.

Grtz,
--
Rik Wasmus
Oct 13 '06 #4

Rik napisal(a):
Rik wrote:
is there a _way_ in PHP to get the available locales without shellacces?

:-)

Grtz,
--
Rik Wasmus
Yes, there is. You can use setlocale() and as second argument pass 0.
Then setlocale() will return current setting. For example:

echo setlocale(LC_TIME, 0);

Oct 13 '06 #5
Rik
Mateusz Markowski wrote:
Rik napisal(a):
>>is there a _way_ in PHP to get the available locales without
shellacces?

Yes, there is. You can use setlocale() and as second argument pass 0.
Then setlocale() will return current setting. For example:

echo setlocale(LC_TIME, 0);
It does, but that isn't what I mean: I want a list of the available locales
without the use of fpassthru()/exec() etc.

Grtz,
--
Rik Wasmus
Oct 13 '06 #6

Rik wrote:
Kim André Akerĝ wrote:
Rik wrote:
Hi all,

is there a in PHP to get the available locales without shellacces
(i.e. locale -a)?

Grtz,
Does this do anything for you? ->

<pre><?php passthru("locale -a"); ?></pre>

The <pre></preis just for the sake of formatting. Whether or not the
above code line will work, depends on the system configuration (ie.
the ability to run external commands may be disabled by the
administrator).

Well, that's the problem: I cannot start external programs. Here on my own
server it's no problem, but it's for a dynamic package that has to work on
a lot of different servers, where running an external program is often
blocked. Looping through hundreds of possibilities and checking for false
is a big pain in this case, but the only solution I've found so far.

Grtz,
--
Rik Wasmus
Hi

Not totally sure about this but you may be able to open the directory
the locale files are stored in. If the NLSPATH or XNLSPATH variables
are set in $_ENV and the file permissions/php settings allow it then
you could check what translation files are in the locale directory.

There's not much chance of it working on every server though, safe_mode
and open_basedir just get in the way. Would making a link to the
locale dir in a readable directory let the locale dir be checked?

Oct 13 '06 #7

Rik napisal(a):
Mateusz Markowski wrote:
Rik napisal(a):
>is there a _way_ in PHP to get the available locales without
shellacces?
Yes, there is. You can use setlocale() and as second argument pass 0.
Then setlocale() will return current setting. For example:

echo setlocale(LC_TIME, 0);

It does, but that isn't what I mean: I want a list of the available locales
without the use of fpassthru()/exec() etc.
So maybe try:

/*Your locale path*/
$path = "/usr/share/locale/";
$h = opendir($path);
while ($file = readdir($h))
$locales[] = $file;

But I have no idea if it works on non unix systems.

Oct 13 '06 #8

Tim Hunt wrote:
Rik wrote:
Kim André Akerĝ wrote:
Rik wrote:
>
>Hi all,
>>
>is there a in PHP to get the available locales without shellacces
>(i.e. locale -a)?
>>
>Grtz,
>
Does this do anything for you? ->
>
<pre><?php passthru("locale -a"); ?></pre>
>
The <pre></preis just for the sake of formatting. Whether or not the
above code line will work, depends on the system configuration (ie.
the ability to run external commands may be disabled by the
administrator).
Well, that's the problem: I cannot start external programs. Here on my own
server it's no problem, but it's for a dynamic package that has to workon
a lot of different servers, where running an external program is often
blocked. Looping through hundreds of possibilities and checking for false
is a big pain in this case, but the only solution I've found so far.

Grtz,
--
Rik Wasmus

Hi

Not totally sure about this but you may be able to open the directory
the locale files are stored in. If the NLSPATH or XNLSPATH variables
are set in $_ENV and the file permissions/php settings allow it then
you could check what translation files are in the locale directory.

There's not much chance of it working on every server though, safe_mode
and open_basedir just get in the way. Would making a link to the
locale dir in a readable directory let the locale dir be checked?
Erm I'm wrong about XNLSPATH, its an empty directory on my system and x
windows wont even be on most servers..will it?). If nlspath is in $_ENV
it could be useful though.

Oct 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: garykpdx | last post by:
Is there some sort of tutorial on locales or the locale module? I can't seem to find a list showing all possible locales. I made 'en' work alright, but when I tried 'de' or 'de_DE' or 'es_ES',...
1
by: jetmarc | last post by:
Hi. I hope that .javascript is the correct group for this question. I have a device with embedded webserver. Its page offers to reset the device, with the following javascript function: ...
7
by: Dennis Gearon | last post by:
If I've read everything right, in order to get: multiple languages on a site with the functionality of ALL of: REGEX LIKE Correctly sorted text
4
by: B.D. | last post by:
Can anyone explain way the transformation to upper case doesn't work correctly in the following code if PROBLEM is defined but works correctly if it's not defined? I'm using VC 7.1 #include...
3
by: Joshua Stewart | last post by:
Hi, I am trying to characterise a problem I am seeing on our C#/C++ xml driven application. We have recently added some basic Spanish language support to our application, but it seems that there...
2
by: Adrian | last post by:
Hi All, Is there anyway to change what isspace thinks is a space character. I am parsing some log files and it would be nice to just read a field as what ever is between quotes or between 's ie...
4
by: Jamey Shuemaker | last post by:
A2k2 with user-level security and all preventive measures, vis a vis, Security FAQ enabled or enacted. I've got three DBs, which due to size constraints can't, or rather, probably shouldn't be...
3
by: George Sakkis | last post by:
I'm trying to figure out why Popen captures the stderr of a specific command when it runs through the shell but not without it. IOW: cmd = if 1: # this captures both stdout and stderr as...
4
by: Gilles Ganault | last post by:
Hello What does it take to support locales? The following test code found on the PHP site doesn't work as planned: ======= setlocale(LC_TIME, "C"); echo strftime("%A"); setlocale(LC_TIME,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.