31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
import os
|
|
|
|
po_path = 'locale/ar/LC_MESSAGES/django.po'
|
|
with open(po_path, 'r', encoding='utf-8') as f:
|
|
lines = f.readlines()
|
|
|
|
new_lines = []
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
if line.startswith('msgid "Add New Truck"'):
|
|
new_lines.append(line)
|
|
i += 1
|
|
if i < len(lines) and lines[i].startswith('msgstr'):
|
|
new_lines.append('msgstr "تسجيل شاحنة"\n')
|
|
i += 1
|
|
# Check if there was a fuzzy flag before this entry
|
|
# In .po files, flags come before msgid
|
|
else:
|
|
new_lines.append(lines[i])
|
|
i += 1
|
|
elif line.startswith('#, fuzzy') and i + 1 < len(lines) and (lines[i+1].startswith('msgid "Add New Truck"') or (i + 2 < len(lines) and lines[i+2].startswith('msgid "Add New Truck"'))):
|
|
# Skip fuzzy if it's for Add New Truck
|
|
i += 1
|
|
else:
|
|
new_lines.append(line)
|
|
i += 1
|
|
|
|
with open(po_path, 'w', encoding='utf-8') as f:
|
|
f.writelines(new_lines)
|
|
print("Updated django.po manually") |