You may want to remove all languages, then install only the LanguagePackages you really want.

Removing Unwanted Languages

So you don't want all these extra pages cluttering your newly setup wiki. There are some easy steps to get rid of them.

Moving files without your language's marker to another directory

# moin 1.2.x:
cd data/text
mkdir unwanted
grep -L "##language:.*en" * | xargs --replace mv {} unwanted/

# moin 1.3.x:
# Warning - many pages are incorrectly tagged with #language en, so this won't catch everything
# See below for a script that will get everything in 1.3.2
# Change to the directory with the underlay/ subdirectory - either in your instance, or in the share folder
cd $INSTANCE
# Make a place to move the unwanted pages
mkdir -p unwanted/pages
# One-liner to find the pages marked with something other than #language en
find underlay -name 00000001 | xargs grep -e "^#language [^e][^n]" | cut -d"/" -f1-3 | sort | uniq | xargs -i mv "{}" unwanted/pages

This will move the files/pages that do not have the 'en' language marker to a directory named "unwanted/". Replace 'en' with the language you want to preserve.

Moin 1.3.2 - Moving Non-English Pages Manually

Here is a script that does the heavy lifting. Run it as root in the directory with the underlay/ subdirectory -- -- JohnWhitlock 2005-01-25 04:34:58

move_non-english.bash

Replacement "OTHERS" list for Moin 1.3.5 -- JasonStirling 2005-08-26 18:23:43

OTHERS="
(c38d)ndicePorT(c3ad)tulos
CambiosRecientes
(e7bbb4e59fbae69599e7a88b)
GalletasDeLaFortuna
MoinMoin(2f)InstallationsAnleitung
NombreWiki
P(c3a1)ginaInicial
P(c3a1)ginasAbandonadas
PomocPrzyFormatowaniu
SystemPagesInSpanishGroup
Tama(c3b1)oDeP(c3a1)gina
Vers(c3a3)oXslt
XsltV(c3a1)ltozat
"

Moin 1.3.3/1.3.4 - Move all system pages except for [languages of your choice]

Here is a small PHP5 script that reduces the system pages to the languages of your choice. It has been tested successfully on Windows XP but should work also on other systems. -- RogerOegretir 2005-03-15 15:39:24

<?php
/**
 * remove unwanted/unused languages
 * -> tested with MoinMoin 1.3.3/1.3.4 and PHP 5.x, WinXP
 * it should run on Linux too with little changes
 */

// config
$dest_dir = "unwanted_pages";
$languages_wanted = "de|en"; # enter as much languages as you want, separated by '|'

// check current dir
if( !preg_match("/underlay$/", getcwd()) || !is_dir('pages')) {
        echo "Please run this script in the MoinMoin underlay directory";
        exit;
}

// create destination
if(!is_dir($dest_dir))
        mkdir($dest_dir);

// php5s new SPL
$it = new DirectoryIterator('pages');

foreach($it as $sub_dir) {

        // really a subdir?
        if($sub_dir->isDot() || !$sub_dir->isDir())
                continue;

        // read page
        $data = file_get_contents("pages/$sub_dir/revisions/00000001");

        // skip pages without language tag
        if(!preg_match("/^#language/m", $data)) {
                continue;

        // check for unwanted languages
        } else {
                if(!preg_match("/^#language ($languages_wanted)/m", $data)) {
                        echo "moving -> $sub_dir ...\n";
                        system("move pages/$sub_dir $dest_dir/$sub_dir >nul");
                        # system("mv pages/$sub_dir $dest_dir/$sub_dir > /dev/nul");
                        # system("rmdir \"pages\\$sub_dir\" /s /q"); # if you are really sure
                }
        }
}

echo "finished.";

?>

I found out that on W2K the move command does not work with very long file names like (d0a0d0b0d0b7d0bcd0b5d180d18bd0a1d182d180d0b0d0bdd0b8d186) (error: "filename or extension too long"). The rmdir command does. Just uncomment it (and comment the move line). -- RogerOegretir 2005-03-15 16:29:46

Here is a Python script that works in a similar fashion:

from glob import glob
from os import renames
from os.path import join, dirname, basename, normpath, abspath

def pages_by_lang(pagesdir):
    """Returns a dictionary of #language to page path."""
    pages = {}
    for path in glob(join(pagesdir,'*','revisions', '00000001')):
        pages.setdefault(scan_for_lang(path), 
            []).append(basename(dirname(dirname(normpath(path)))))
    return pages

def scan_for_lang(path):
    """Returns #language from path or 'None' if #language not found."""
    for line in file(path):
        # We assume no language declaration can occur after a blank line
        if line[0] != '#':
            break
        if line.startswith('#language '):
            return line.split()[1]
    return None

def move_unwanted(pagesdir, unwanteddir, wantedlangs=[None, 'en']):
    pages = pages_by_lang(pagesdir)
    for lang, paths in pages.iteritems():
        if lang not in wantedlangs:
            for pagedir in paths:
                renames(join(pagesdir, pagedir), join(unwanteddir, pagedir))

if __name__ == '__main__':
    move_unwanted(abspath('./underlay/pages'), abspath('./unwanted/pages'))

Alternative way

The wiki contain SystemPagesGroup, which contain SystemPagesInLanguageGroup pages. Each of these pages contain the complete list of localized language for that language. One can use the list of pages to move or delete files. This list is usually more correct than the #language tag, because broken list shows in MoinMaster, and usually get fixed, while wrong or missing language tag is hidden.

Making buttons always use English

Do something like this in your wikiconfig.cfg file (tested with 1.3.5, also with 1.5.5):

   1 # Remove unwanted languages
   2 from MoinMoin import i18n
   3 wantedLanguages = {}
   4 for name in ['en', 'he']:
   5     wantedLanguages[name] = i18n.languages[name]
   6 i18n.languages = wantedLanguages
   7 del i18n, wantedLanguages, name

This should work with any version, no patching needed.

MoinMoin: ScriptMarket/RemovingUnwantedLanguages (last edited 2007-10-29 19:08:52 by localhost)