wichert / lingua

Translation toolkit for Python
Other
45 stars 32 forks source link

Files-from parameter doesn't find files #85

Open raspi opened 7 years ago

raspi commented 7 years ago

If you use --files-from parameter pot-create doesn't find file(s).

 $VENV/bin/pot-create --config "lang.conf" --files-from locale-files.txt --output /dev/null
 Can not find file /home/raspi/projects/test/foo/__init__.py
$ stat /home/raspi/projects/test/foo/__init__.py
  File: '/home/raspi/projects/test/foo/__init__.py'
  Size: 2071        Blocks: 8          IO Block: 4096   tavallinen tiedosto
Device: 801h/2049d  Inode: 4069600     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/   raspi)   Gid: ( 1000/   raspi)
Access: 2017-02-21 09:21:38.523260776 +0200
Modify: 2017-02-21 09:21:38.523260776 +0200
Change: 2017-02-21 09:21:38.523260776 +0200
 Birth: -

locale-files.txt:

/home/raspi/projects/test/foo/__init__.py
/home/raspi/projects/test/foo/lib/__init__.py
/home/raspi/projects/test/foo/models/__init__.py
/home/raspi/projects/test/foo/models/user.py
/home/raspi/projects/test/foo/include/layouts.py
/home/raspi/projects/test/foo/include/urli18n.py
/home/raspi/projects/test/foo/include/security.py
/home/raspi/projects/test/foo/include/__init__.py
/home/raspi/projects/test/foo/include/routes.py
/home/raspi/projects/test/foo/database/__init__.py
/home/raspi/projects/test/foo/database/loginlog.py
/home/raspi/projects/test/foo/database/user.py
/home/raspi/projects/test/foo/views/dberrors.py
/home/raspi/projects/test/foo/views/errors.py
/home/raspi/projects/test/foo/views/__init__.py
/home/raspi/projects/test/foo/views/views.py
/home/raspi/projects/test/foo/views/templates/form_login.pt
/home/raspi/projects/test/foo/views/templates/500.pt
/home/raspi/projects/test/foo/views/templates/languages.pt
/home/raspi/projects/test/foo/views/templates/footer.pt
/home/raspi/projects/test/foo/views/templates/home.pt
/home/raspi/projects/test/foo/views/templates/default_layout.pt
/home/raspi/projects/test/foo/views/templates/form_logout.pt
/home/raspi/projects/test/foo/views/templates/main_menu.pt
/home/raspi/projects/test/foo/views/templates/403.pt
/home/raspi/projects/test/foo/views/templates/logout.pt
/home/raspi/projects/test/foo/views/templates/error_database.pt
/home/raspi/projects/test/foo/views/templates/404.pt
/home/raspi/projects/test/foo/views/templates/login.pt
wichert commented 7 years ago

That looks like a bug.

Looking at this and your other ticket I'm wondering what your are trying to do. Can you explain what the problem is you're trying to solve?

raspi commented 7 years ago

I'm trying to write shell script which updates main default.pot and after that all other locales of Pyramid application.

#!/bin/bash -e
export APP=$1
export HERE="$(dirname $(readlink -f "$0"))"
export PYTHONDONTWRITEBYTECODE=1
export VENV="$HERE"

python3 -m venv $VENV

./rm_python_cache.sh

LOCALEFILES="$HERE/locale-files.txt"

echo "Generating file list.."
find "$HERE/$APP" -type f -iname "*.py" > "$LOCALEFILES"
find "$HERE/$APP" -type f -iname "*.pt" >> "$LOCALEFILES"

LOCALEDIR="$HERE/$APP/locale"
mkdir -p "$LOCALEDIR"
LOCALEPOT="$LOCALEDIR/default.pot"

strace -e trace=open $VENV/bin/pot-create --config "lang.conf" --files-from $LOCALEFILES --output "$LOCALEPOT"
#$VENV/bin/pot-create --config "lang.conf" --directory $APP/* --output "$LOCALEPOT"
echo ""

cd "$LOCALEDIR"

echo "Updating .po files.."
find . -type f -iname "*.po" -exec bash -c "echo 'file: {}'; msgmerge --update '{}' '$LOCALEPOT'" \;
echo ""

echo "Generating .mo files.."
find . -type f -iname "*.po" -print0 | while read -d '' -r file; do 
  MOFILE="${file%.*}.mo"
  echo "${file} -> $MOFILE"
  msgfmt "${file}" -o "$MOFILE" 
done
echo ""

echo "Listing files:"
find . -type f 
echo ""

cd -

echo "Done."
wichert commented 7 years ago

Doesn't https://github.com/wichert/lingua/blob/master/docs/examples/i18n.sh already do that?

raspi commented 7 years ago

I wasn't aware of that script. Sometimes I also need to add files to translatable filelist with certain rules and exclude or include some files. So that script is just very stripped down version.