]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add a $config['plugins']['locale_path'] which can be set to override the individual...
authorBrion Vibber <brion@pobox.com>
Fri, 1 Oct 2010 02:18:46 +0000 (19:18 -0700)
committerBrion Vibber <brion@pobox.com>
Fri, 1 Oct 2010 02:23:42 +0000 (19:23 -0700)
This will apply to *ALL* plugins in *ALL* languages, so should probably only be used when doing site customization...

You'd probably do:

  $config['site']['locale_path'] = '/srv/awesome/data/locale';
  $config['plugins']['locale_path'] = '/srv/awesome/data/locale';

with a structure like:
srv/
  awesome/
    data/
      locale/
        en/
          LC_MESSAGES/
            statusnet.po
            OpenID.po
            AnonymousFave.po

etc, all alongside each other. You could separate plugins from the core if you like.

Where locale files have not already been generated, you can build one for a plugin like so:

  php scripts/update_po_templates.php --plugin=MyPlugin

and pull out the template file:

  plugins/MyPlugin/locale/MyPlugin.pot

Edit that (make sure you at least set the CHARSET, probably to UTF-8) and save your customized .po
files into the structure as above, and use msgfmt to generate .mo files for final output.

lib/default.php
lib/plugin.php

index 6200abada1ea85bdfea4bb1d2f3c6505292d9379..45e35e83d380c8326e1008ccf2a6fb59fee1fa1f 100644 (file)
@@ -298,6 +298,7 @@ $default =
                                  'WikiHashtags' => null,
                                  'RSSCloud' => null,
                                  'OpenID' => null),
+              'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
               ),
         'admin' =>
         array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license')),
index ee57f590435f8a2093d066247ade5b634e72f82f..3f84afa27e867a2c3c950a2ded5d1ae46cde44d7 100644 (file)
@@ -88,7 +88,12 @@ class Plugin
         $class = get_class($this);
         if (substr($class, -6) == 'Plugin') {
             $name = substr($class, 0, -6);
-            $path = INSTALLDIR . "/plugins/$name/locale";
+            $path = common_config('plugins', 'locale_path');
+            if (!$path) {
+                // @fixme this will fail for things installed in local/plugins
+                // ... but then so will web links so far.
+                $path = INSTALLDIR . "/plugins/$name/locale";
+            }
             if (file_exists($path) && is_dir($path)) {
                 bindtextdomain($name, $path);
                 bind_textdomain_codeset($name, 'UTF-8');