功能:词条去重
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, python
- Domain
- internationalization
Research direction
The issue proposes a Python script to remove duplicate entries from static sections in locals.js. Start by checking how the localization files are structured and whether duplicate keys are present. The example script is only a proposal; done means the intended duplicate entries are removed without losing comments or other content.
Written by the indexing model from the issue text.
Description
目前打算使用 python 脚本自动检测并去除重复词条
这是示例脚本:
import re
def remove_duplicates(file_path):
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# 匹配所有 "static" 部分
static_matches = re.finditer(r'"static": \{([\s\S]*?)\}', content)
if not static_matches:
print('未找到 "static" 部分。')
return
new_content = content # 用于存储整体替换后的内容
for match in static_matches:
static_content = match.group(1)
lines = static_content.split('\n')
seen = set() # 用于存储已出现的键名
unique_lines = [] # 存储去重后的行
# 遍历每一行,检查重复
for line in lines:
stripped_line = line.strip()
if stripped_line and not stripped_line.startswith('//'): # 排除注释和空行
key_match = re.match(r'"(.*?)":', stripped_line) # 提取键名
if key_match:
key = key_match.group(1)
if key in seen:
print(f'重复项:{key}')
continue
seen.add(key)
unique_lines.append(line) # 保留非重复项、注释和空行
# 将去重后的内容重新组装
unique_content = '\n'.join(unique_lines)
new_content = new_content.replace(static_content, unique_content)
# 写入去重后的文件
with open(file_path, 'w', encoding='utf-8') as file:
file.write(new_content)
print('所有重复项已移除并保存至文件。')
if __name__ == "__main__":
# 文件路径
file_path = './locals.js' # 替换为你的文件路径
remove_duplicates(file_path)
- Dominant language
- JavaScript
- Stars
- 35.1k
- Forks
- 2k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 9
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from maboloshi/github-chinese
-
添加报告文档问题的模板Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
maboloshi/github-chinese#823 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
maboloshi/github-chinese#810 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 44/100
maboloshi/github-chinese#809 · 2 comments ·
Maintainers usually reply within 1 day
-
项目首页除了顶栏几乎没有翻译Openbug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
maboloshi/github-chinese#803 · 1 comment · 2 reactions ·
Maintainers usually reply within 1 day
-
请求翻译
Difficulty 3/5 1-2 days Newbie friendliness 55/100
maboloshi/github-chinese#802 · 2 comments ·
Maintainers usually reply within 1 day
All issues in maboloshi/github-chinese
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
microsoft/monaco-editor#5577 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
obsidianmd/obsidian-help#1169 ·
Maintainers usually reply within 2 days
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepPossibly taken @albertteoh claimed this today. Opendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
jaegertracing/jaeger-ui#4739 ·
Maintainers usually reply within 1 day