mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 11:32:21 +08:00
translations: remove locations (#25826)
* Remove locations * no line nos old-commit-hash: 35f624c628c0e8f2e936ba945bdc516a8d17517e
This commit is contained in:
@@ -29,10 +29,7 @@ class TestTranslations(unittest.TestCase):
|
||||
def _read_translation_file(path, file):
|
||||
tr_file = os.path.join(path, f"{file}.ts")
|
||||
with open(tr_file, "r") as f:
|
||||
# ignore locations when checking if translations are updated
|
||||
lines = [line for line in f.read().splitlines() if
|
||||
not line.strip().startswith(LOCATION_TAG)]
|
||||
return "\n".join(lines)
|
||||
return f.read()
|
||||
|
||||
def test_missing_translation_files(self):
|
||||
for name, file in self.translation_files.items():
|
||||
@@ -93,6 +90,13 @@ class TestTranslations(unittest.TestCase):
|
||||
self.assertTrue(all([re.search("%[0-9]+", t) is None for t in numerusform]),
|
||||
"Plural translations must use %n, not %1, %2, etc.: {}".format(numerusform))
|
||||
|
||||
def test_no_locations(self):
|
||||
for name, file in self.translation_files.items():
|
||||
with self.subTest(name=name, file=file):
|
||||
for line in self._read_translation_file(TRANSLATIONS_DIR, file).splitlines():
|
||||
self.assertFalse(line.strip().startswith(LOCATION_TAG),
|
||||
f"Line contains location tag: {line.strip()}, remove all line numbers.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<context>
|
||||
<name>InputDialog</name>
|
||||
<message numerus="yes">
|
||||
<location filename="../qt/widgets/input.cc" line="+168"/>
|
||||
<source>Need at least %n character(s)!</source>
|
||||
<translation>
|
||||
<numerusform>Need at least %n character!</numerusform>
|
||||
@@ -15,7 +14,6 @@
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message numerus="yes">
|
||||
<location filename="../qt/util.cc" line="+82"/>
|
||||
<source>%n minute(s) ago</source>
|
||||
<translation>
|
||||
<numerusform>%n minute ago</numerusform>
|
||||
@@ -23,7 +21,6 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location line="+3"/>
|
||||
<source>%n hour(s) ago</source>
|
||||
<translation>
|
||||
<numerusform>%n hour ago</numerusform>
|
||||
@@ -31,7 +28,6 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location line="+3"/>
|
||||
<source>%n day(s) ago</source>
|
||||
<translation>
|
||||
<numerusform>%n day ago</numerusform>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ def update_translations(vanish=False, plural_only=None, translations_dir=TRANSLA
|
||||
|
||||
for file in translation_files.values():
|
||||
tr_file = os.path.join(translations_dir, f"{file}.ts")
|
||||
args = f"lupdate -locations relative -recursive {UI_DIR} -ts {tr_file}"
|
||||
args = f"lupdate -locations none -recursive {UI_DIR} -ts {tr_file}"
|
||||
if vanish:
|
||||
args += " -no-obsolete"
|
||||
if file in plural_only:
|
||||
|
||||
Reference in New Issue
Block a user