[PHP] dgettext vs. xgettext

2007-11-23 Thread news_yodpeirs
Hi!

I'm using dgettext() with different domains in one set of scripts (or even 
in one script). When extracting the messages with xgettext I would like to 
specify an option to get only messages for one domain, like getting all 
messages from calls to dgettext('foobar',...) and ignore all others. 
Otherwise it wouldn't be possible to knwo which message belongs to which 
domain. Did anyone else came across this problem? And, even more interesing: 
Does anyone have a solution for this?

With kind regards
Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: dgettext vs. xgettext

2007-11-26 Thread news_yodpeirs
No ideas? Am I the only one using different domains with dgettext? What's 
the sense of it if you can't get the translations apart?

Any hint is welcome ...

[EMAIL PROTECTED] schrieb im Newsbeitrag 
news:[EMAIL PROTECTED]
 Hi!

 I'm using dgettext() with different domains in one set of scripts (or even
 in one script). When extracting the messages with xgettext I would like to
 specify an option to get only messages for one domain, like getting all
 messages from calls to dgettext('foobar',...) and ignore all others.
 Otherwise it wouldn't be possible to know which message belongs to which
 domain. Did anyone else came across this problem? And, even more 
 interesing:
 Does anyone have a solution for this?

 With kind regards
 Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: dgettext vs. xgettext

2007-11-27 Thread news_yodpeirs
So long, I solved it by myself. As I'm only using dgettext() and the domain 
always is represented by a constant, I simply collect all php-files, then 
preg_match_all() occurences of dgettext() (with domain in mind), put the 
texts in the different corresponding files and, as I'm on the way, convert 
them into the appropriate charset, merge the new files with the existing 
ones and compile them (using the gnu-gettext binaries). So on the fly I got 
all my texts stored and compiled, preserving the old translations.

Thank you for listening. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Nested include/require not working in 5.2

2007-11-28 Thread news_yodpeirs
Did you look for files named config.php? I would try to find out which file 
is loaded instead of the wanted one. Maybe you could use 
fopen('config.php','r',TRUE); and check the contents of that file to get an 
idea where it comes from? If it happens only with a file of this name, I 
would assume that there is a file of this name somewhere in the include_path 
...

HTH, Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP RFC # 0001 --- List Etiquette

2007-11-28 Thread news_yodpeirs
Wouldn't this be solved if the email is simply an answer to the thread 
instead of a new, separate email? Within the thread about nested files
(http://www.nabble.com/Nested-include-require-not-working-in-5.2-tf4882937.html)
 
there was also an email with a changed subject ((SOLVED) was added), but 
it stays in the thread as it was an answer to the thread. I think, the main 
problem is, not to answer to the thread but simply sending a new email.

Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Structured Code vs. Performance

2007-11-29 Thread news_yodpeirs
I got different portions of code only used for certain purposes (who don't 
;-)?). But what, in your opinion (better: in your experience) would be the 
best regarding script-performance: Putting each code-portion in a separate 
file and include it if required, putting it in a constant-dependent 
if-structure (if (defined('FOO')  FOO) {class foo{}; function foo(); ...}) 
or simply let it be parsed every time?

My first choice is using separate files, but if a file e.g. only contains 20 
lines, I fear it would take much longer to include the file against simply 
parsing these lines in the existing file. And as parsing is done really 
fast, there might be no real performance-loss in case of not using the 
mentioned code. With the constant-dependent if-structure I don't know if 
there are any performance-benefits if FOO isn't defined or defined as FALSE.

Looks for me a bit like a philosophical question, but maybe you have 
something to say about it nevertheless. A good thing for me would be 
something like: up to 125 lines of code you get an adequate performance with 
simply parsing it every time, with more than 125 lines you would get a 
better performance with using separate files - just kidding, surely the 
number of lines in this case is 42 ;-).

Looking forward to your answers
Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Structured Code vs. Performance

2007-11-29 Thread news_yodpeirs
Thank you for the answers.

My abstract:

Use separate files for separate code. Easy to maintain, no real loss in 
performance. That's fine, as I'm just doing so (like if I need a database 
abstraction, I include dbas.php and if dbas.php needs some miscellaneous 
functionality, it includes misc.php by itself - so no worry for me to think 
about the dependencies of the scripts). Yes, that makes use of 
require_once() et al., but as I didn't plan to use something like ACP, it 
seems to be no problem so far.

Use absolute pathnames when including. That's too what I do, as I don't want 
scripts to be found accidentally - see the thread about inlcuding config.php 
for that ;-).

Caching code might be another possibility for gaining speed - I will think 
about that later, thank you for the hints.

And last but not least: First make your code work in a proper and 
maintainable way. Then think (and ask) for speed. And don't expect people to 
assume you have done it this way ;-).

If someone wants to complete this abstract, it would be appreciated, 
otherwise I'm done.

Thank you again!
Thomas 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Functions with Static Variables vs. Classes

2007-11-29 Thread news_yodpeirs
For some simple applications I use a function to collect values in a static
variable and to return them when called in a special way, just like this
(fairly senseless) example:
  function example($elem='') {
static $store = array();
if (!func_num_args()) return($store);
... do something with $elem ...
$store[] = $elem;
  }
I would call this a singleton-micro-class, as it works like a class with
data and methods, but there is always only one of it, having only one
method.

Why do I? Because I dont need to worry about variablescope as if I would use
global variables and I dont have to initialize an object before the first
call (with the scope-problem again). I simply can call it everywhere and
everytime.

Do you have any comments to this approach?

Thomas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Variable Names

2007-11-29 Thread news_yodpeirs
The manual says:

In order to use variable variables with arrays, you have to resolve an 
ambiguity problem. That is, if you write $$a[1] then the parser needs to 
know if you meant to use $a[1] as a variable, or if you wanted $$a as the 
variable and then the [1] index from that variable. The syntax for resolving 
this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second.

Does this help you?

Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structured Code vs. Performance

2007-11-29 Thread news_yodpeirs
Just to be curious:

when something like

if (defined('FOO')  FOO) {
  class foo{};
  function foo(){};
}

is parsed and FOO is not defined, will the code inside be parsed 
nevertheless? Or is anything inside skipped, leading to a (fragments of 
microseconds) faster handling of the code? Thus to go to my original 
question concerning speed: Would I save time with this construct as I would 
save it with skipping an include()?

Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Functions with Static Variables vs. Classes

2007-11-29 Thread news_yodpeirs
From: Zoltán Németh [EMAIL PROTECTED]
   function example($elem='') {
 static $store = array();

 AFAIK the above line should cause an error on the second run of the
 function, as you declare the same static variable for the second time.

 or am I wrong?

I think so - otherwise static Variables would be quite senseless. The line
starting with static is (so do I think) once evaluated at compile-time or at
the first run and the ignored.

Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Structured Code vs. Performance

2007-11-29 Thread news_yodpeirs
 they have a word very suitable to this situation in dutch 'mierenneuken',
 personally I'd stick with pretty girls.

OT: Couldn't translate that in german, the nearest approach seems to be 
Haarspalterei but unfortunately for me this seems not to match the 
situation. And it doesn't meet pretty girls too :-D.

But so in fact conditional definitions are absolutely useless - apart from 
giving the parser some work without using it's outcome?

Thomas 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: One more data formatting question

2007-11-29 Thread news_yodpeirs
How about
  $foo = str_replace('nbsp;','',$foo);
?

Or could there be an 'nbsp;' in a context where it shouldn't be replaced?

Thomas 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php