Skip to content

Commit

Permalink
reuse dictionnary for nav tx content
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 19, 2024
1 parent d085692 commit 159ffa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ jobs:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

- name: Push source files to Transifex
if: ${{ github.event_name == 'push' }}
if: ${{ github.event_name != 'pull_request' }}
run: ./tx push
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

- name: Pull translations from Transifex
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'opengisch/signalo' && github.actor != 'dependabot[bot]' }}
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'opengisch/signalo' && github.actor != 'dependabot[bot]' }}
run: |
./tx pull --translations --all --minimum-perc 10
./tx status
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}

- name: Translate Mkdocs config
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == 'opengisch/signalo' && github.actor != 'dependabot[bot]' }}
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'opengisch/signalo' && github.actor != 'dependabot[bot]' }}
run: |
./scripts/mkdocs_tx.py -s fr update_config
./scripts/mkdocs_tx_commit.sh
Expand Down
16 changes: 6 additions & 10 deletions website/scripts/mkdocs_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def read_config(file_path: str):


def nav_config(config):
_nav_config = []
_nav_config = {}

def add_nav_entry(title, content):
if title:
_nav_config.append(title)
_nav_config[title] = title
for _entry in content:
if type(_entry) == str:
# this is pointing to a page directly, skipping
Expand Down Expand Up @@ -57,7 +57,6 @@ def create_translation_source(config_path, source_path):

def update_config(config_path, source_path, source_language):
config = read_config(config_path)
_nav_config = nav_config(config)

found = False
for plugin in config["plugins"]:
Expand All @@ -76,13 +75,10 @@ def update_config(config_path, source_path, source_language):
yaml = YAML()
tx = yaml.load(f)

assert len(_nav_config) == len(tx["nav"])

lang["nav_translations"] = {}
for i in range(len(tx["nav"])):
lang["nav_translations"][_nav_config[i]] = (
tx["nav"][i] or _nav_config[i]
)
for _title, _translation in tx["nav"].items():
if not _translation:
tx["nav"][_title] = _title
lang["nav_translations"] = tx["nav"]

try:
lang["palette"] = copy.deepcopy(config["theme"]["palette"])
Expand Down

0 comments on commit 159ffa7

Please sign in to comment.