Skip to content

Commit

Permalink
Makefile: respect $(MLANG), and settle changelog.po down
Browse files Browse the repository at this point in the history
po4a and polib disagree on the formatting of a .po file, so run po4a
again to format it.
  • Loading branch information
xry111 committed Sep 18, 2022
1 parent 4f5207d commit 2eb56b9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 62 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ __pycache__
local.mk
pot
po4a.cfg
po4a-changelog.cfg
.*.swp
.*.swo
28 changes: 23 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,38 @@ default: html

LFS_EN = lfs-en
MLANG = zh_CN
CMD_FIND_XML = find $(LFS_EN) -type f -name '*.xml' ! -name 'lfs-l10n.xml'
CMD_FIND_XML = find $(LFS_EN) -type f -name '*.xml' \
! \( -name 'lfs-l10n.xml' -or -name 'changelog.xml' \)
XML_FILES = $(shell $(CMD_FIND_XML))
POT_DIRS = $(sort $(patsubst $(LFS_EN)/%, pot/%, $(dir $(XML_FILES))))
PO_FILES = $(patsubst $(LFS_EN)/%.xml, $(MLANG)/%.po, $(XML_FILES))
MKPO4ACFG = ./mkpo4acfg.py $(MLANG)

-include local.mk

$(PO_FILES) &: $(XML_FILES) mkpo4acfg.py changelogtranslator.py
$(PO_FILES) &: $(XML_FILES) mkpo4acfg.py
mkdir -pv $(POT_DIRS)
$(CMD_FIND_XML) | ./mkpo4acfg.py > po4a.cfg
$(CMD_FIND_XML) | $(MKPO4ACFG) > po4a.cfg
po4a --no-translations po4a.cfg

$(MLANG)/chapter01/changelog.po: lfs-en/chapter01/changelog.xml \
changelogtranslator.py \
templatetranslator.py
mkdir -pv pot/chapter01
echo lfs-en/chapter01/changelog.xml | $(MKPO4ACFG) > po4a-changelog.cfg
po4a --no-translations po4a-changelog.cfg
./changelogtranslator.py $(MLANG)
# Run again. polib does not agree with po4a on line wrappings
# in the .po file, so we need to settle it down.
po4a --no-translations --force po4a-changelog.cfg

MXML_FILES = $(patsubst $(LFS_EN)/%.xml, $(MLANG)/book/%.xml, $(XML_FILES))
BOOK_FILES = $(patsubst $(LFS_EN)/%, %, $(shell find $(LFS_EN) -type f -not -path "$(LFS_EN)/.git"))
MBOOK_FILES = $(patsubst %, $(MLANG)/book/%, $(BOOK_FILES))

.PHONY: html booksrc nochunks pdf pofiles

pofiles: $(PO_FILES)
pofiles: $(PO_FILES) $(MLANG)/chapter01/changelog.po

html: booksrc
rm -rf $(MLANG)/book/render # without this tidy may be stupidly slow
Expand Down Expand Up @@ -51,9 +63,15 @@ booksrc: $(MBOOK_FILES) $(ORIG_FILES)

$(MXML_FILES) &: $(XML_FILES) $(PO_FILES) mkpo4acfg.py
mkdir -pv $(POT_DIRS)
$(CMD_FIND_XML) | ./mkpo4acfg.py > po4a.cfg
$(CMD_FIND_XML) | $(MKPO4ACFG) > po4a.cfg
po4a po4a.cfg

$(MLANG)/book/chapter01/changelog.xml: $(LFS_EN)/chapter01/changelog.xml \
$(MLANG)/chapter01/changelog.po
mkdir -pv pot/chapter01
echo lfs-en/chapter01/changelog.xml | $(MKPO4ACFG) > po4a-changelog.cfg
po4a po4a-changelog.cfg

$(MLANG)/book/%: $(LFS_EN)/%
mkdir -pv "$(@D)"
cp -v $< $@
Expand Down
2 changes: 1 addition & 1 deletion lfs-en
Submodule lfs-en updated from 6cfe85 to cdc605
6 changes: 3 additions & 3 deletions mkpo4acfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import sys

print(r'''\
[po4a_langs] zh_CN
[po4a_paths] pot/$master.pot $lang:$lang/$master.po
print('[po4a_langs]', sys.argv[1])

print(r'''[po4a_paths] pot/$master.pot $lang:$lang/$master.po
[options] --porefs file
[options] --keep 0
[options] --package-name "\"Linux From Scratch\""
Expand Down
2 changes: 1 addition & 1 deletion templatetranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def translate_one(self, filename, language):
if not os.path.exists(realname):
print(realname, 'does not exist.')
return
po = polib.pofile(realname)
po = polib.pofile(realname, wrapwidth = 76)
for entry in po:
for reg in self.regexps:
if language in reg[1]:
Expand Down
87 changes: 35 additions & 52 deletions zh_CN/chapter01/changelog.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Linux From Scratch 11.0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2022-09-17 20:37+0800\n"
"POT-Creation-Date: 2022-09-18 20:50+0800\n"
"PO-Revision-Date: 2022-02-05 22:45+0800\n"
"Last-Translator: Xi Ruoyao <[email protected]>\n"
"Language-Team: None <[email protected]>\n"
Expand All @@ -32,14 +32,13 @@ msgid ""
"version is probably already available. To find out, please check one of the "
"mirrors via <ulink url=\"&lfs-root;mirrors.html\"/>."
msgstr ""
"这是 Linux From Scratch 手册的 &version; 版本,发布于 "
"&releasedate;。如果该版本已经发布了六个月或更久,可能已经发布了更好的新版本。如果要查询是否有新版本,通过 <ulink "
"url=\"&lfs-root;mirrors.html\"/> 访问一个 LFS 镜像站。"
"这是 Linux From Scratch 手册的 &version; 版本,发布于 &releasedate;。如果该版"
"本已经发布了六个月或更久,可能已经发布了更好的新版本。如果要查询是否有新版"
"本,通过 <ulink url=\"&lfs-root;mirrors.html\"/> 访问一个 LFS 镜像站。"

#. type: Content of: <sect1><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"Below is a list of changes made since the previous release of the book."
msgid "Below is a list of changes made since the previous release of the book."
msgstr "下面是本书自上一版本发布以来的更新日志。"

#. type: Content of: <sect1><itemizedlist><title>
Expand All @@ -52,8 +51,7 @@ msgstr "更新日志记录:"
msgid "2022-09-15"
msgstr "2022 年 9 月 15 日"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to file-5.43. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -62,8 +60,7 @@ msgstr ""
"[bdubbs] — 更新到 file-5.43。修复 <ulink url=\"&lfs-ticket-"
"root;5113\">#5113</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to linux-5.19.8. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -72,8 +69,7 @@ msgstr ""
"[bdubbs] — 更新到 linux-5.19.8。修复 <ulink url=\"&lfs-ticket-"
"root;5111\">#5111</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to gawk-5.2.0. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -82,8 +78,7 @@ msgstr ""
"[bdubbs] — 更新到 gawk-5.2.0。修复 <ulink url=\"&lfs-ticket-"
"root;5108\">#5108</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to meson-0.63.2. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -92,8 +87,7 @@ msgstr ""
"[bdubbs] — 更新到 meson-0.63.2。修复 <ulink url=\"&lfs-ticket-"
"root;5106\">#5106</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to ninja-1.11.1. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -102,36 +96,32 @@ msgstr ""
"[bdubbs] — 更新到 ninja-1.11.1。修复 <ulink url=\"&lfs-ticket-"
"root;5103\">#5103</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to bc-6.0.2. Fixes <ulink url=\"&lfs-ticket-"
"root;5102\">#5102</ulink>."
msgstr ""
"[bdubbs] — 更新到 bc-6.0.2。修复 <ulink url=\"&lfs-ticket-"
"root;5102\">#5102</ulink>。"
"[bdubbs] — 更新到 bc-6.0.2。修复 <ulink url=\"&lfs-ticket-root;5102\">#5102</"
"ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Fix the location of udev rules in eudev. Fixes <ulink "
"url=\"&lfs-ticket-root;5112\">#5112</ulink>."
"[bdubbs] - Fix the location of udev rules in eudev. Fixes <ulink url=\"&lfs-"
"ticket-root;5112\">#5112</ulink>."
msgstr ""
"[bdubbs] — 修复 eudev 报告的 udev 规则安装位置。修复 <ulink url=\"&lfs-ticket-"
"root;5112\">#5112</ulink>。"
"[bdubbs] — 修复 eudev 报告的 udev 规则安装位置。修复 <ulink url=\"&lfs-"
"ticket-root;5112\">#5112</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Remove a warning for egrep and fgrep that makes tests for some "
"packages fail."
msgstr "[bdubbs] — 移除 egrep 和 fgrep 中导致一些软件包测试失败的警告。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Delete an empty binutils man page. Fixes <ulink url=\"&lfs-"
Expand All @@ -145,25 +135,23 @@ msgstr ""
msgid "2022-09-10"
msgstr "2022 年 9 月 10 日"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[pierre] - Add <option>--enable-default-pie</option> and <option>--enable-"
"default-ssp</option> to GCC build. Rationale and some reports at <ulink "
"url=\"&lfs-ticket-root;5107\">#5107</ulink>."
"default-ssp</option> to GCC build. Rationale and some reports at <ulink url="
"\"&lfs-ticket-root;5107\">#5107</ulink>."
msgstr ""
"[pierre] — 在构建 GCC 时使用 <option>--enable-default-pie</option> 和 "
"<option>--enable-default-ssp</option> 选项。其原因和一些测试结果记录在 <ulink url=\"&lfs-"
"ticket-root;5107\">#5107</ulink> 中。"
"<option>--enable-default-ssp</option> 选项。其原因和一些测试结果记录在 "
"<ulink url=\"&lfs-ticket-root;5107\">#5107</ulink> 中。"

#. type: Content of: <sect1><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid "2022-09-07"
msgstr "2022 年 9 月 7 日"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to shadow-4.12.3. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -172,8 +160,7 @@ msgstr ""
"[bdubbs] — 更新到 shadow-4.12.3。修复 <ulink url=\"&lfs-ticket-"
"root;5101\">#5101</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to Python3-3.10.7. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -182,8 +169,7 @@ msgstr ""
"[bdubbs] — 更新到 Python3-3.10.7。修复 <ulink url=\"&lfs-ticket-"
"root;5109\">#5109</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to linux-5.19.7. Fixes <ulink url=\"&lfs-ticket-"
Expand All @@ -192,33 +178,30 @@ msgstr ""
"[bdubbs] — 更新到 linux-5.19.7。修复 <ulink url=\"&lfs-ticket-"
"root;5099\">#5099</ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to less-608. Fixes <ulink url=\"&lfs-ticket-"
"root;5104\">#5104</ulink>."
msgstr ""
"[bdubbs] — 更新到 less-608。修复 <ulink url=\"&lfs-ticket-"
"root;5104\">#5104</ulink>。"
"[bdubbs] — 更新到 less-608。修复 <ulink url=\"&lfs-ticket-root;5104\">#5104</"
"ulink>。"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid ""
"[bdubbs] - Update to grep-3.8. Fixes <ulink url=\"&lfs-ticket-"
"root;5105\">#5105</ulink>."
msgstr ""
"[bdubbs] — 更新到 grep-3.8。修复 <ulink url=\"&lfs-ticket-"
"root;5105\">#5105</ulink>。"
"[bdubbs] — 更新到 grep-3.8。修复 <ulink url=\"&lfs-ticket-root;5105\">#5105</"
"ulink>。"

#. type: Content of: <sect1><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid "2022-09-01"
msgstr "2022 年 9 月 1 日"

#. type: Content of:
#. <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#. type: Content of: <sect1><itemizedlist><listitem><itemizedlist><listitem><para>
#: lfs-en/chapter01/changelog.xml
msgid "[bdubbs] - LFS-11.2 released."
msgstr "[bdubbs] - LFS-11.2 发布。"

0 comments on commit 2eb56b9

Please sign in to comment.