Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Makefile providing various facilities to manage translations
  2. TEMPLATE = editor.pot
  3. POFILES = $(wildcard *.po)
  4. LANGS = $(POFILES:%.po=%)
  5. all: update merge
  6. update:
  7. @cd ../..; python3 editor/translations/extract.py
  8. merge:
  9. @for po in $(POFILES); do \
  10. echo -e "\nMerging $$po..."; \
  11. msgmerge -w 79 -C $$po $$po $(TEMPLATE) > "$$po".new; \
  12. mv -f "$$po".new $$po; \
  13. msgattrib --output-file=$$po --no-obsolete $$po; \
  14. done
  15. check:
  16. @for po in $(POFILES); do msgfmt -c $$po -o /dev/null; done
  17. # Generate completion ratio from statistics string such as:
  18. # 2775 translated messages, 272 fuzzy translations, 151 untranslated messages.
  19. # First number can be 0, second and third numbers are only present if non-zero.
  20. include-list:
  21. @list=""; \
  22. threshold=0.20; \
  23. exclude_ctl="ar bn fa he hi ml si ta te ur"; \
  24. for po in $(POFILES); do \
  25. lang=`basename $$po .po`; \
  26. if `grep -q $$lang <<< $$exclude_ctl`; then continue; fi; \
  27. res=`msgfmt --statistics $$po -o /dev/null 2>&1 | sed 's/[^0-9,]*//g'`; \
  28. complete=`cut -d',' -f1 <<< $$res`; \
  29. fuzzy_or_untranslated=`cut -d',' -f2 <<< $$res`; \
  30. untranslated_maybe=`cut -d',' -f3 <<< $$res`; \
  31. if [ -z "$$fuzzy_or_untranslated" ]; then fuzzy_or_untranslated=0; fi; \
  32. if [ -z "$$untranslated_maybe" ]; then untranslated_maybe=0; fi; \
  33. incomplete=`expr $$fuzzy_or_untranslated + $$untranslated_maybe`; \
  34. if `awk "BEGIN {exit !($$complete / ($$complete + $$incomplete) > $$threshold)}"`; then \
  35. list+="$$lang,"; \
  36. fi; \
  37. done; \
  38. echo $$list;