check_lang_folder_sync.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. #
  3. # Check if folders with localized documentation are in sync
  4. #
  5. # 1. Traverse each folder with language version and generate a sorted list
  6. # of all the files inside
  7. # 2. Compare the sorted lists of files and flag differences
  8. #
  9. # Note:
  10. # All differences between folders with language versions should be resolved
  11. # before releasing documentation
  12. #
  13. RESULT=0
  14. STARS='***************************************************'
  15. find en -type f | cut -d/ -f2- | sort > file_list_en
  16. find zh_CN -type f | cut -d/ -f2- | sort > file_list_zh_CN
  17. # format is to display new or different filenames
  18. DIFF_FORMAT="--unchanged-line-format= --old-line-format=[en]:%L --new-line-format=[zh_CN]:%L"
  19. FOLDER_DIFFERENCES=$(diff $DIFF_FORMAT file_list_en file_list_zh_CN)
  20. if ! [ -z "$FOLDER_DIFFERENCES" ]; then
  21. echo "$STARS"
  22. echo "Build failed due to the following differences in 'en' and 'zh_CN' folders:"
  23. echo "$FOLDER_DIFFERENCES"
  24. echo "$STARS"
  25. echo "Please synchronize contents of 'en' and 'zh_CN' folders to contain files with identical names"
  26. RESULT=1
  27. fi
  28. # remove temporary files
  29. rm file_list_en file_list_zh_CN
  30. exit $RESULT