-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
289 additions
and
48 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
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,16 @@ | ||
# pylint: disable=import-error,ungrouped-imports | ||
|
||
import sys | ||
|
||
from utils import is_installed, parse_qt_dependency | ||
|
||
if __name__ == "__main__": | ||
dep = parse_qt_dependency() | ||
if dep == "PySide6": | ||
from PySide6.scripts.pyside_tool import lrelease | ||
|
||
elif is_installed("PySide6"): | ||
from PySide6.scripts.pyside_tool import lrelease | ||
else: | ||
sys.exit("No lrelease can be found in current Python environment.") | ||
sys.exit(lrelease()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from scripts.utils import SupportedQtDependencies | ||
from tests import ASSETS_DIR, filter_available_qt_dependencies, invoke_script | ||
from tests.test_lupdate import invoke_lupdate | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"qt_dependency", | ||
filter_available_qt_dependencies(["PySide6"]), | ||
) | ||
def test_lrelease_help(qt_dependency: SupportedQtDependencies): | ||
result = invoke_script("lrelease", ["-help"], qt_dependency) | ||
assert result.returncode == 0 | ||
assert len(result.stdout.decode("utf-8")) > 0 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"qt_dependency", | ||
filter_available_qt_dependencies(["PySide6"]), | ||
) | ||
def test_lrelease_sample_ts(qt_dependency: SupportedQtDependencies): | ||
filename_no_ext = "sample" | ||
|
||
try: | ||
os.remove(get_assets_path(f"{filename_no_ext}.qm")) | ||
except FileNotFoundError: | ||
pass | ||
|
||
invoke_lupdate(filename_no_ext, qt_dependency) | ||
|
||
result = invoke_script( | ||
"lrelease", [get_assets_path(f"{filename_no_ext}.ts")], qt_dependency | ||
) | ||
assert result.returncode == 0 | ||
assert len(result.stdout.decode("utf-8")) > 0 | ||
|
||
os.remove(get_assets_path(f"{filename_no_ext}.qm")) | ||
|
||
|
||
def get_assets_path(filename: str) -> str: | ||
return os.path.join(ASSETS_DIR, "linguist", filename) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { firstValueFrom } from 'rxjs' | ||
import type { CommandDeps } from '../commands' | ||
import { getTargetDocumentUri } from '../commands' | ||
import { run } from '../run' | ||
import { getToolCommand$ } from '../tool-utils' | ||
|
||
export async function compileTranslations( | ||
{ extensionUri }: CommandDeps, | ||
...args: any[] | ||
) { | ||
const targetDocumentUriResult = getTargetDocumentUri(...args) | ||
|
||
if (targetDocumentUriResult.kind !== 'Success') return targetDocumentUriResult | ||
|
||
const translationFile = targetDocumentUriResult.value | ||
|
||
const getToolCommandResult = await firstValueFrom( | ||
getToolCommand$({ | ||
tool: 'lrelease', | ||
extensionUri, | ||
resource: translationFile, | ||
}), | ||
) | ||
|
||
if (getToolCommandResult.kind !== 'Success') return getToolCommandResult | ||
|
||
return run({ | ||
command: [ | ||
...getToolCommandResult.value.command, | ||
translationFile.fsPath, | ||
...getToolCommandResult.value.options, | ||
], | ||
}) | ||
} |
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,12 @@ | ||
import * as assert from 'node:assert' | ||
import { commands } from 'vscode' | ||
import { EXTENSION_NAMESPACE } from '../../../constants' | ||
|
||
suite('compileTranslations', () => { | ||
test('should include the command', async () => | ||
assert.ok( | ||
(await commands.getCommands(true)).includes( | ||
`${EXTENSION_NAMESPACE}.compileTranslations`, | ||
), | ||
)) | ||
}) |
Oops, something went wrong.