summaryrefslogtreecommitdiff
path: root/lib/language.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-08-03 16:04:54 -0700
committerEvan Prodromou <evan@status.net>2010-08-03 16:04:54 -0700
commit004e42e3e0606f0f9e5c8b6cd4512e5d870cd56e (patch)
treeab895f7609c8afeeadf3439c860b69d0cffcbb5e /lib/language.php
parentd2234580357349a6887a2321e69d11de7bb29106 (diff)
parentfdd9aa58e3caf87096e1c1dcfa8b2f286b04e4b1 (diff)
Merge remote branch 'gitorious/1.0.x' into 1.0.x
Diffstat (limited to 'lib/language.php')
-rw-r--r--lib/language.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/language.php b/lib/language.php
index 8009adc9b..1805707ad 100644
--- a/lib/language.php
+++ b/lib/language.php
@@ -61,7 +61,7 @@ if (!function_exists('dpgettext')) {
* Not currently exposed in PHP's gettext module; implemented to be compat
* with gettext.h's macros.
*
- * @param string $domain domain identifier, or null for default domain
+ * @param string $domain domain identifier
* @param string $context context identifier, should be some key like "menu|file"
* @param string $msgid English source text
* @return string original or translated message
@@ -106,7 +106,7 @@ if (!function_exists('dnpgettext')) {
* Not currently exposed in PHP's gettext module; implemented to be compat
* with gettext.h's macros.
*
- * @param string $domain domain identifier, or null for default domain
+ * @param string $domain domain identifier
* @param string $context context identifier, should be some key like "menu|file"
* @param string $msg singular English source text
* @param string $plural plural English source text
@@ -180,7 +180,11 @@ function _m($msg/*, ...*/)
}
/**
- * Looks for which plugin we've been called from to set the gettext domain.
+ * Looks for which plugin we've been called from to set the gettext domain;
+ * if not in a plugin subdirectory, we'll use the default 'statusnet'.
+ *
+ * Note: we can't return null for default domain since most of the PHP gettext
+ * wrapper functions turn null into "" before passing to the backend library.
*
* @param array $backtrace debug_backtrace() output
* @return string
@@ -206,12 +210,19 @@ function _mdomain($backtrace)
if (DIRECTORY_SEPARATOR !== '/') {
$path = strtr($path, DIRECTORY_SEPARATOR, '/');
}
- $cut = strpos($path, '/plugins/');
- if ($cut) {
- $cut += strlen('/plugins/');
+ $plug = strpos($path, '/plugins/');
+ if ($plug === false) {
+ // We're not in a plugin; return default domain.
+ return 'statusnet';
+ } else {
+ $cut = $plug + 9;
$cut2 = strpos($path, '/', $cut);
- if ($cut && $cut2) {
- $final = substr($path, $cut, $cut2 - $cut);
+ if ($cut2) {
+ $cached[$path] = substr($path, $cut, $cut2 - $cut);
+ } else {
+ // We might be running directly from the plugins dir?
+ // If so, there's no place to store locale info.
+ return 'statusnet';
}
}
$cached[$path] = $final;