function _mdomain return bad domain
function _mdomain return bad domain
| Issue ID: | 2329 |
| Issue Category: | bug |
| Component: | core |
| Priority: | lowest |
| Status: | fixed |
| Assigned: | brion |
| Version: | 0.9 |
| Milestone: | 0.9 |
| Keywords: | i18n i10n |
code in function _mdomain() will return bad domain, e.g. return "n" in my test environment.
it is cause by $cut will not be null, when there is no 'pluginins' in $path
$cut = strpos($path, '/plugins/') + 9;
and when no domain match, we should not return "". I think it should be "statusnet".
so the here in _mdomain() should be changed from:
$cut = strpos($path, '/plugins/') + 9;
$cut2 = strpos($path, '/', $cut);
if ($cut && $cut2) {
$cached[$path] = substr($path, $cut, $cut2 - $cut);
} else {
return null;
}
to:
if(strpos($path, '/plugins/')){
$cut = strpos($path, '/plugins/') + 9;
$cut2 = strpos($path, '/', $cut);
}
if ($cut && $cut2) {
$cached[$path] = substr($path, $cut, $cut2 - $cut);
} else {
return "statusnet";
}

Updates
#1
I used statusnet 0.9.2
#2
Good catch!
Fixed on master in 697a9948df3c9d4275b3525227007bfd5a1c5709 ... I'm still having it return null for the case where we're not in a plugins directory (null means 'use default domain' so we don't have to specific it explicitly). Tested and confirmed that eg _m('Profile') correctly returns localized results from the main localization set when run from console.php.
#3
Hi
leave return to null will cause some string is not translated.
maybe you should test something like _m("MENU", "Admin")
please see attachment for screen with null and with statusnet.
----
Replying to [comment:3 brion]:
> Good catch!
>
> Fixed on master in 697a9948df3c9d4275b3525227007bfd5a1c5709 ... I'm still having it return null for the case where we're not in a plugins directory (null means 'use default domain' so we don't have to specific it explicitly). Tested and confirmed that eg _m('Profile') correctly returns localized results from the main localization set when run from console.php.
#4
I can't get the files added here.
please find the files in flickr:
http://www.flickr.com/photos/hileon/4645598595/
http://www.flickr.com/photos/hileon/4646213466/
#5
Bah... looks like the PHP wrapper functions over gettext don't all accept null for domain the way the low-level library is specced to.
The parameter gets casted to a C string internally; some functions such as textdomain() are then specifically checking for empty string or "0" and passing NULL to the low-level libary, but others like dcgettext() aren't. I'll tweak...
#6
[master f4539b5] Ticket 2329 followup: my clever 'let it use the default' was foiled by PHP gettext module not quite exposing a compatible interface as the backend gettext library. (Most funcs squash null domain parameter into '' empty string, which isn't interpreted as 'use the current default'.)
You can also subscribe to the
RSS feed for updates to this issue.