Add ability to get the GitHub URL for any repo to generate xliff files from markdown#7
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors markdownTranslate for readability and adds a new md2xliff CLI command in l10nUtil, including logic to derive a raw GitHub URL from the repository’s origin remote instead of relying on a hard-coded constant.
Changes:
- Add
md2xliffcommand tol10nUtilto convert Markdown to XLIFF. - Replace hard-coded raw GitHub repo URL with dynamic detection from
git remote origin. - Reformat/tidy various call sites and helper functions for brevity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
source/markdownTranslate.py |
Removes hard-coded raw GitHub URL and introduces repo URL detection helper; mostly formatting refactors. |
source/l10nUtil.py |
Adds new md2xliff subcommand wiring to markdownTranslate.generateXliff. |
Comments suppressed due to low confidence (1)
source/markdownTranslate.py:97
getGithubRepoURL()is annotated/documented to returnstr | None, but it never returnsNone(it raises on failure) and its callers treat it as astr. Either change the return type/docstring tostror implement aNone/fallback behavior and handle it in callers to avoid type-check failures and confusing API semantics.
def getGithubRepoURL() -> str | None:
"""
Get the GitHub repository URL from git remote origin.
return: The raw GitHub URL for the repository, or None if it cannot be determined.
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks @nvdaes - could you make the PR description and title more clear? |
|
@seanbudd , I've updated the description for this PR. I've tested this locally in two different repos, including NVDA and nvdal10n. |
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
|
@seanbudd , now all check pass, but note that this is not true for pyright locally. |
|
Yes I think it should be |
|
Please note that l10nUtil.py seems to only provide generateXliff; updateXliff should also be provided. |
Please note that l10nUtil.py seems to only provide generateXliff; updateXliff should also be provided. Yes, I think you're right. I'll create another PR if someone doesn't create it before me. |
|
By the way, can you fix nvdaes#5 at the same time? |
|
@wmhn1872265132 , I've created PR #8, but I don't want how to fix nvdaes#5. |
Description
This PR adds the possibility to generate xliff files from markdown for any GitHub repository.
Previously, this was possible just for NVDA.
Development approach
A new function has been created to get the raw URL for the content of any GitHub repository. This can be used to run an md2xliff command from a GitHub repository.
Tests
I've tested this locally, running the md2xliff command in two different repos, including NVDA and nvdal10n from NV Access.