Skip to content

Clean up parameters in locale files #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
328 changes: 99 additions & 229 deletions nettacker/locale/ar.yaml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion nettacker/locale/bn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ database_connect_fail: ডাটাবেস সংযোগ করতে পা
database_connection_failed: সংযোগ নির্বাচিত ডাটাবেস থেকে ব্যর্থ হয়েছে
define_white_list: "হোয়াইট লিস্ট হোস্টকে সংজ্ঞায়িত করুন, এটি আলাদা করুন, (উদাহরণ: 127.0.0.1, 1 9 2.168.0.1/24, 10.0.0.1-10.0.0.255 )"
engine: ইঞ্জিন
filtered_content: ... [রিপোর্টে পূর্ণ সামগ্রী দেখুন]
filtered_content: '... [রিপোর্টে পূর্ণ সামগ্রী দেখুন]'
engine_input: ইঞ্জিন ইনপুট বিকল্প
Invalid_whatcms_api_key: "{0}"
searching_whatcms_database: whatcms.org এ CMS অনুসন্ধান করা হচ্ছে...
Expand All @@ -35,6 +35,8 @@ cannot_run_api_server: আপনি নিজেই এপিআই সার্
error_target: লক্ষ্য উল্লেখ করতে পারবেন না
error_target_file: "ফাইলটি খুলতে অক্ষম (টার্গেট) নির্দিষ্ট করতে পারে না: {0}"
error_username: "ব্যবহারকারী নামটি ফাইলটি খুলতে অক্ষম হতে পারে না: {0}"
error_passwords: "Cannot specify the password(s), unable to open file: {0}"
error_wordlist: "Cannot specify the word(s), unable to open file {0}"
exclude_scan_method: "{0} বাদ দিতে স্ক্যান পদ্ধতি বেছে নিন"
file_write_error: ফাইল "{0}" লেখার যোগ্য নয়!
library_not_supported: লাইব্রেরি [{0}] সমর্থন নয়!
Expand Down Expand Up @@ -107,8 +109,10 @@ username_list: ব্যবহারকারীর নাম(গুলি) ত
verbose_mode: Verbose মোড স্তর (0-5) (ডিফল্ট 0)
wrong_hardware_usage: "আপনি হার্ডওয়্যার ব্যবহারের জন্য এই প্রোফাইলগুলির একটি নির্বাচন করতে হবে। (নিম্ন, স্বাভাবিক, উচ্চ, সর্বাধিক)"
invalid_scan_id: আপনার স্ক্যান আইডি বৈধ নয়
compare_scans: compare current scan to old scans using the unique scan_id
compare_report_path_filename: "তুলনা রিপোর্ট সংরক্ষণের জন্য ফাইল পাথ"
no_scan_to_compare: "তুলনা করার জন্য scan_id পাওয়া যায়নি"
compare_report_saved: "তুলনা ফলাফল সংরক্ষিত হয়েছে: {0}"
build_compare_report: "তুলনা রিপোর্ট তৈরি করা হচ্ছে"
finish_build_report: "তুলনা রিপোর্ট সম্পূর্ণ হয়েছে"
user_wordlist: "Allows users to enter their own wordlist"
361 changes: 105 additions & 256 deletions nettacker/locale/de.yaml

Large diffs are not rendered by default.

359 changes: 105 additions & 254 deletions nettacker/locale/el.yaml

Large diffs are not rendered by default.

350 changes: 100 additions & 250 deletions nettacker/locale/es.yaml

Large diffs are not rendered by default.

341 changes: 105 additions & 236 deletions nettacker/locale/fa.yaml

Large diffs are not rendered by default.

353 changes: 100 additions & 253 deletions nettacker/locale/fr.yaml

Large diffs are not rendered by default.

159 changes: 76 additions & 83 deletions nettacker/locale/hi.yaml

Large diffs are not rendered by default.

343 changes: 103 additions & 240 deletions nettacker/locale/hy.yaml

Large diffs are not rendered by default.

339 changes: 104 additions & 235 deletions nettacker/locale/id.yaml

Large diffs are not rendered by default.

300 changes: 100 additions & 200 deletions nettacker/locale/it.yaml

Large diffs are not rendered by default.

317 changes: 103 additions & 214 deletions nettacker/locale/iw.yaml

Large diffs are not rendered by default.

272 changes: 98 additions & 174 deletions nettacker/locale/ja.yaml

Large diffs are not rendered by default.

290 changes: 97 additions & 193 deletions nettacker/locale/ko.yaml

Large diffs are not rendered by default.

344 changes: 104 additions & 240 deletions nettacker/locale/nl.yaml

Large diffs are not rendered by default.

330 changes: 103 additions & 227 deletions nettacker/locale/ps.yaml

Large diffs are not rendered by default.

368 changes: 116 additions & 252 deletions nettacker/locale/pt-br.yaml

Large diffs are not rendered by default.

336 changes: 104 additions & 232 deletions nettacker/locale/ru.yaml

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions nettacker/locale/sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
"""
Usage:
./sync.py en.yaml locale_folder

Description:
1. Reads in en.yaml as the reference file.
2. Scans the specified folder for YAML files (except en.yaml).
3. For each locale file, generates a new YAML file with keys in the order of en.yaml.
If a key exists in the locale file, its value is used; otherwise, the value from en.yaml is used.
4. The output preserves original formatting, including quotes and backslashes,
and prevents automatic line wrapping.
"""

import os
import sys

from ruamel.yaml import YAML

if len(sys.argv) != 3:
print("Usage: {} en.yaml locale_folder".format(sys.argv[0]))
sys.exit(1)

en_file = sys.argv[1]
locale_folder = sys.argv[2]

yaml = YAML()
yaml.preserve_quotes = True # Preserve original quotes
yaml.width = 4096 # Set a large width to avoid automatic line wrapping

# Load the English reference file
with open(en_file, "r", encoding="utf-8") as f:
en_data = yaml.load(f)

# Process all .yaml files in the folder except the English file
for filename in os.listdir(locale_folder):
if not filename.endswith(".yaml"):
continue
if filename == os.path.basename(en_file):
continue

target_path = os.path.join(locale_folder, filename)
output_path = os.path.join(locale_folder, filename)

# Load the target locale file
with open(target_path, "r", encoding="utf-8") as f:
target_data = yaml.load(f)

# Build a new dictionary following the order of keys in en.yaml
new_data = {}
for key in en_data:
if key in target_data:
new_data[key] = target_data[key]
else:
new_data[key] = en_data[key]

# Output the result to a new file
with open(output_path, "w", encoding="utf-8") as f:
yaml.dump(new_data, f)

print("Updated file has been output to", output_path)
Loading