fix.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/sh
  2. # fix some English and ASCII specific stuff which can not be handled by po4a
  3. # This should be handled by po4a, but if some pages are not done yet
  4. # we will need to do it manually.
  5. sed -e '/encoding=/s|ISO-8859-1|UTF-8|' -i $(find -name \*.xml)
  6. # Let tidy output UTF-8
  7. sed -e '/output-encoding:/s|latin1|utf8|' -i tidy.conf
  8. # Remove two seds causing encoding error in UTF-8
  9. sed -e '/xa9/d' -i Makefile
  10. sed -e 's|<book>|<book lang="zh_cn">|' -i index.xml
  11. sed -e '/xreflabel/s|Chapter.nbsp.1 - Mailing Lists|第 1 章 - 邮件列表|' \
  12. -e '/xreflabel/s|Chapter.nbsp.1 - Mirror sites|第 1 章 - 镜像站|' \
  13. -i chapter01/resources.xml
  14. sed -e '/xreflabel/s|Chapter.nbsp.\([0-9]\+\)|第 \1 章|' \
  15. -i chapter*/chapter*.xml
  16. sed -e '/xreflabel/s|Host System Requirements|宿主系统需求|' \
  17. -i chapter02/hostreqs.xml
  18. sed -e '/xreflabel/s|General Compilation Instructions|通用编译说明|' \
  19. -i part3intro/generalinstructions.xml
  20. sed -e '/xreflabel/s|Toolchain Technical Notes|工具链技术说明|' \
  21. -i part3intro/toolchaintechnotes.xml
  22. sed -e '/xreflabel/s|Package build instructions|软件包构建说明|' \
  23. -i part3intro/generalinstructions.xml
  24. sed -e '/xreflabel/s|"gcc-pass1"|"第一遍的 GCC"|' \
  25. -i chapter05/gcc-pass1.xml
  26. sed -e '/xreflabel/s|"gcc-pass2"|"第二遍的 GCC"|' \
  27. -i chapter06/gcc-pass2.xml
  28. sed -e '/xreflabel/s|Appendix|附录|' -i \
  29. appendices/acknowledgments.xml \
  30. appendices/acronymlist.xml \
  31. appendices/dependencies.xml \
  32. appendices/license.xml \
  33. appendices/scripts.xml \
  34. appendices/udev-rules.xml
  35. sed -e 's/Approximate build time/估计构建时间/' \
  36. -e 's/Required disk space/需要硬盘空间/' \
  37. -e 's/Installation depends on/安装依赖于/' \
  38. -e 's/Test suite depends on/测试依赖于/' \
  39. -e 's/Must be installed before/必须在下列软件包之前安装/' \
  40. -e 's/Optional dependencies/可选依赖项/' \
  41. -i general.ent
  42. sed -e 's/less than/不到/' \
  43. -e 's/typically about/一般约/' \
  44. -e 's/about \(.*\) with tests/计入测试为约 \1/' \
  45. -e '/encoding=/s/ISO-8859-1/UTF-8/' \
  46. -i packages.ent
  47. reldate=$(grep 'releasedate' general.ent |
  48. sed 's/.*"\(.*\)".*/\1/;s/st\|nd\|rd\|th//');
  49. if reldate_cn=$(LANG=zh_CN.UTF-8 \
  50. date -d "$reldate" "+%Y 年 %b %d 日" \
  51. 2>/dev/null); then
  52. reldate_cn=$(echo "$reldate_cn" | sed 's/月/ &/')
  53. sed "/releasedate/s/\".*\"/\"${reldate_cn}\"/" -i general.ent
  54. fi
  55. # Some buggy comments produced by po4a are adding extra empty lines.
  56. # Remove them.
  57. sed -n '
  58. 1h
  59. 1!{
  60. /<screen[^\n]*><!--.*-->\n/!H
  61. g
  62. /<screen[^\n]*><!--.*-->\n/{
  63. s/\(<screen[^\n]*>\)<!--.*-->\n/\1/
  64. p
  65. n
  66. h
  67. }
  68. }
  69. $p
  70. ' -i \
  71. chapter02/hostreqs.xml \
  72. chapter06/ncurses.xml \
  73. chapter08/glibc.xml \
  74. chapter08/flex.xml \
  75. chapter08/ninja.xml \
  76. chapter08/texinfo.xml \
  77. chapter08/systemd.xml \
  78. chapter09/networkd.xml \
  79. chapter09/network.xml \
  80. chapter09/consoled.xml \
  81. chapter09/usage.xml
  82. # Apply lfs-l10n.xml patch, if it's not applied
  83. grep "Simplified Chinese" stylesheets/lfs-xsl/lfs-l10n.xml ||
  84. patch -N -p1 -i ../patches/lfs-l10n.xml.patch