Skip to content

Commit

Permalink
reuse fontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 19, 2024
1 parent 9e49f27 commit 6f0bc67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions website/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ruamel.yaml==0.18.6
pre-commit==3.6.2
python-frontmatter==1.1.0
8 changes: 5 additions & 3 deletions website/scripts/mkdocs_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ def update_config(config_path, source_path, source_language):
lang["palette"] = copy.deepcopy(config["theme"]["palette"])
i = 0
for palette in tx["theme"]["palette"]:
lang["palette"][i]["toggle"]["name"] = palette["toggle"][
"name"
]
_name = (
palette["toggle"]["name"]
or config["theme"]["palette"][i]["toggle"]["name"]
)
lang["palette"][i]["toggle"]["name"] = _name
i += 1
except KeyError:
print("No theme/palette/toggle/name to translate")
Expand Down
15 changes: 5 additions & 10 deletions website/scripts/transifex_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import glob
import os
import re

import frontmatter

TX_ORGANIZATION = "opengisch"
TX_PROJECT = "signalo-website"
Expand Down Expand Up @@ -42,17 +43,11 @@ def create_transifex_config():
# Get relative path of file
relative_path = os.path.relpath(file, start=root)

tx_slugs = [re.match(r"^tx_slug: +(.*)", line) for line in open(file)]
tx_slugs = [t for t in tx_slugs if t]
tx_slug = frontmatter.load(file).get("tx_slug", None)

if not tx_slugs:
if not tx_slug:
print(f"No TX slug found for {relative_path}")

if len(tx_slugs) > 1:
print(f"More than 1 TX slug found for {relative_path}")

if tx_slugs:
tx_slug = tx_slugs[0].group(1)
else:
print(
f"Found file with tx_slug defined: `{relative_path}`, `{tx_slug}`"
)
Expand Down

0 comments on commit 6f0bc67

Please sign in to comment.