Makefile 1.6 KB

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