-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
576e40b
commit 9fe298d
Showing
10 changed files
with
1,993 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
1,891 changes: 1,891 additions & 0 deletions
1,891
MethodicConfigurator/locale/pt/LC_MESSAGES/MethodicConfigurator.po
Large diffs are not rendered by default.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
MethodicConfigurator/locale/pt/LC_MESSAGES/extract_missing_translations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator | ||
SPDX-FileCopyrightText: 2024 Amilcar do Carmo Lucas <[email protected]> | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
''' | ||
|
||
import os | ||
import gettext | ||
|
||
def extract_missing_translations(po_file, output_file): | ||
# Set up the translation catalog | ||
language = gettext.translation('messages', localedir=os.path.dirname(po_file), languages=['zh_CN'], fallback=True) | ||
|
||
# Read the .po file entries | ||
with open(po_file, 'r', encoding='utf-8') as f: | ||
lines = f.readlines() | ||
|
||
missing_translations = [] | ||
|
||
# Iterate through lines to find untranslated msgid | ||
for i, line in enumerate(lines): | ||
line = line.strip() | ||
|
||
if line.startswith('msgid'): | ||
msgid = line.split('"')[1] # Get the msgid string | ||
|
||
# Check if the translation exists | ||
if language.gettext(msgid) == msgid: # If translation is the same as msgid, it's missing | ||
missing_translations.append((i, msgid)) | ||
|
||
# Write untranslated msgids along with their indices to the output file | ||
with open(output_file, 'w', encoding='utf-8') as f: | ||
for index, item in missing_translations: | ||
f.write(f'{index}:{item}\n') | ||
|
||
if __name__ == "__main__": | ||
extract_missing_translations('MethodicConfigurator.po', 'missing_translations.txt') |
45 changes: 45 additions & 0 deletions
45
MethodicConfigurator/locale/pt/LC_MESSAGES/insert_translations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator | ||
SPDX-FileCopyrightText: 2024 Amilcar do Carmo Lucas <[email protected]> | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
''' | ||
|
||
def insert_translations(po_file, translations_file, output_file): | ||
with open(po_file, 'r', encoding='utf-8') as f: | ||
lines = f.readlines() | ||
|
||
with open(translations_file, 'r', encoding='utf-8') as f: | ||
translations_data = f.read().strip().split('\n') | ||
|
||
# Prepare to insert translations | ||
translations = [] | ||
for data in translations_data: | ||
index, translation = data.split(':', 1) # Split the index and the translation | ||
translations.append((int(index), translation.strip())) # Store index and translation as tuple | ||
|
||
insertion_offset = 0 # To track how many lines we've inserted | ||
# To insert the translations correctly | ||
for index, translation in translations: | ||
# Adjust index accounting for previously inserted lines | ||
adjusted_index = index + insertion_offset | ||
|
||
# Check if the next line is an empty msgstr | ||
if (adjusted_index + 1 < len(lines) and | ||
lines[adjusted_index + 1].strip() == 'msgstr ""'): | ||
# Overwrite the empty msgstr line | ||
lines[adjusted_index + 1] = f'msgstr "{translation}"\n' | ||
else: | ||
# Otherwise, insert a new msgstr line | ||
lines.insert(adjusted_index + 1, f'msgstr "{translation}"\n') | ||
insertion_offset += 1 # Increment the offset for each insertion | ||
|
||
# Writing back to a new output file | ||
with open(output_file, 'w', encoding='utf-8') as f: | ||
f.writelines(lines) | ||
|
||
if __name__ == "__main__": | ||
insert_translations('MethodicConfigurator.po', 'translations.txt', 'updated_MethodicConfigurator.po') |
Binary file modified
BIN
+12.1 KB
(2000%)
MethodicConfigurator/locale/zh_CN/LC_MESSAGES/MethodicConfigurator.mo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# ArduPilot Methodic Configurator. | ||
# Copyright (C) 2024 ArduPilot.org | ||
# Copyright (C) 2024 Amilcar Lucas, ArduPilot.org | ||
# SakuraRC_Yang <[email protected]>, 2024. | ||
# | ||
msgid "" | ||
|
@@ -1645,7 +1645,7 @@ msgstr "将参数 %s 重命名为 %s" | |
#: MethodicConfigurator/frontend_tkinter_parameter_editor_table.py:179 | ||
msgid "" | ||
"The parameter '{old_name}' was renamed to '{new_name}'.\n" | ||
"to follow the flight controller connection defined in the component editor window." | ||
"to obey the flight controller connection defined in the component editor window." | ||
msgstr "" | ||
"参数 '{old_name}' 已重命名为 '{new_name}'。\n" | ||
"以遵循组件编辑器窗口中定义的飞行控制器连接。" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters