Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple Python versions #16

Closed
9 tasks done
m-aciek opened this issue Sep 21, 2023 · 2 comments
Closed
9 tasks done

Support for multiple Python versions #16

m-aciek opened this issue Sep 21, 2023 · 2 comments

Comments

@m-aciek
Copy link
Owner

m-aciek commented Sep 21, 2023

  • delete some of the Weblate components to unlock capacity of adding new ones for POC
  • rearrange directories structure for other docs versions
  • add 3.11 translations and sources
  • setup Weblate components and autodiscovery for 3.11
    • update existing components filemasks after moving PO files
  • adapt mirroring script to fetch only one category
  • make .update-pots.py script support multiple Python versions
  • (test translation memory propagation)
@m-aciek
Copy link
Owner Author

m-aciek commented Oct 26, 2023

After moving files updated components with a following script:

from dataclasses import dataclass
from os import getenv
from traceback import print_exc

from tqdm import tqdm
from wlc import Weblate, WeblateException, Project, Translation


@dataclass
class Version:
    number: str

    def is_latest(self):
        return self.number == "3.12"

    def weblate_category_name(self):
        return self.number

    def directory_name(self):
        return self.is_latest() and "latest" or self.number


if __name__ == "__main__":
    weblate_key = getenv('KEY')
    weblate = Weblate(weblate_key, 'https://hosted.weblate.org/api/')
    project = Project(weblate, 'https://hosted.weblate.org/api/projects/python-docs/')
    for component in tqdm(project.list()):
        if component.is_glossary:
            continue
        directory_name = Version(component.category.name).directory_name()
        print(component.filemask.startswith(f'*/{directory_name}'), component.name, component.category.name, component.filemask)
        if not component.filemask.startswith(f'*/{directory_name}'):
            path = component.filemask.removeprefix('*/')
            new_filemask = f'*/{directory_name}/{path}'
            repo_link = f'weblate://python-docs/{directory_name}/bugs'
            print(new_filemask, repo_link)
            try:
                component.patch(filemask=new_filemask, repo=repo_link)
            except WeblateException as exception:
                print_exc()
                print('skipping')

@m-aciek
Copy link
Owner Author

m-aciek commented Jan 18, 2024

@m-aciek m-aciek closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant