StaticMessages.sh 1.64 KB
Newer Older
1 2
#!/usr/bin/env bash

3 4
EXPORTS_POT_DIR=1
FILE_PREFIX=docs_krita_org_
5

6
function export_pot_dir # First parameter will be the path of the directory where we have to store the pot files
7 8
{
    echo "Creating POT files"
9 10 11 12 13 14 15 16
    potdir=$1
    make gettext
    cd _build/gettext
    rm -rf untranslatable_pages.pot untranslatable_pages
    # Flatten the dir structure
    find * -type f -exec bash -c 'new=$(echo "{}" | sed s#/#___#g); mv "{}" "docs_krita_org_$new"' \;
    mv *.pot $potdir
    rm -rf *
17 18
}

19
function import_po_dirs # First parameter will be a path that will be a directory to the dirs for each lang and then all the .po files inside
20
{
21 22
    podir=$1
    mkdir -p locale
23 24
    # for some reason sphinx uses uk_UA instead of uk
    mv $podir/uk $podir/uk_UA
25 26
    # for some reason sphinx uses pt_PT instead of pt
    mv $podir/pt $podir/pt_PT
27 28 29 30
    # These are the language codes that sphinx supports.
    for lang in bn ca cs da de es et eu fa fi fr he hr hu id it ja ko lt lv mk nb_NO ne nl pl pt_BR pt_PT ru si sk sv tr uk_UA vi zh_CN zh_TW
    do
        if [ -d "$podir/$lang" ]; then
31 32 33 34 35 36 37
            rm -rf locale/$lang/LC_MESSAGES
            mkdir -p locale/$lang/LC_MESSAGES
            mv $podir/$lang/*.po locale/$lang/LC_MESSAGES
            cd locale/$lang/LC_MESSAGES
            # Recreate the dir structure
            find * -type f -exec bash -c 'new=$(echo "{}" | sed s#docs_krita_org_##g | sed s#___#/#g); mkdir -p `dirname $new`; mv {} $new' \;
            cd ../../..
38
            rm -rf $podir/$lang
39 40
        fi
    done
41
    ls $podir # This will "complain" about languages that are translated but unsupported in sphinx, once we have one we'll have to think what to do
42
}