Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc259ee1

Browse files
Fix config generation script
1 parent3554fc2 commitc259ee1

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

‎.github/scripts/generate_tx_config.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Please note that this script requires a Transifex API token to run."""
2+
importglob
23
importsubprocess
34
fromfunctoolsimportpartial
45
frompathlibimportPath
@@ -32,20 +33,33 @@ def add_files(version: str):
3233
defname_replacer(match:re.Match[str]):
3334
prefix,resource=match.group("prefix","resource")
3435
override_prefix=prefix.replace("file_filter","trans.zh_CN")
35-
override_resource= (
36+
pattern= (
3637
resource.replace("trans/<lang>/","")
37-
.replace("--","/")
3838
.replace("glossary_","glossary")
39-
.replace("_",".")
39+
.replace("--","/")
40+
.replace("_","?")
4041
)
41-
returnf"{prefix}{resource}\n{override_prefix}{override_resource}"
42-
43-
44-
defpatch_config():
42+
matches=list(glob.glob(pattern.replace(".po",".rst")))
43+
ifnotmatches:
44+
print("missing",pattern)
45+
returnf"{prefix}{resource}\n{override_prefix}{pattern}"
46+
eliflen(matches)==1:
47+
filename=matches[0].replace(".rst",".po").replace("\\","/")
48+
else:
49+
raiseValueError("multi match",resource,pattern,matches)
50+
returnf"{prefix}{resource}\n{override_prefix}{filename}"
51+
52+
53+
defpatch_config(path:str):
4554
tx_config_path=Path(".tx","config")
4655

4756
config_content=tx_config_path.read_text("utf-8")
57+
58+
cwd=os.getcwd()
59+
os.chdir(path)
4860
config_content=FILTER_PATTERN.sub(name_replacer,config_content)
61+
os.chdir(cwd)
62+
4963
tx_config_path.write_text(config_content,"utf-8")
5064

5165

@@ -55,13 +69,14 @@ def patch_config():
5569

5670
parser=ArgumentParser()
5771

58-
parser.add_argument("--token")
59-
parser.add_argument("--version")
72+
parser.add_argument("--token",required=True)
73+
parser.add_argument("--version",required=True)
74+
parser.add_argument("--doc-path",required=True)
6075

6176
params=parser.parse_args()
6277

6378
os.environ["TX_TOKEN"]=params.token
6479

6580
init_project()
6681
add_files(params.version)
67-
patch_config()
82+
patch_config(params.doc_path)

‎.github/scripts/update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
tx=$(realpath ./tx)
44
cd docs||exit 1
5-
$tx pull --languages"$LOCALE"
5+
$tx pull --languages"$LOCALE" -t --use-git-timestamps

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp