Skip to content

Commit

Permalink
Merge pull request #506 from openedx/bmtcril/fix_jinja_loc
Browse files Browse the repository at this point in the history
fix: Don't save intermediate translations files, fix parse error
  • Loading branch information
bmtcril authored Nov 2, 2023
2 parents 8ea4b75 + 934c627 commit ff1115a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 770 deletions.
2 changes: 1 addition & 1 deletion scripts/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

import click
from utils import compile_translations, extract_translations, get_text_for_translations
from translate_utils import compile_translations, extract_translations, get_text_for_translations


@click.command()
Expand Down
11 changes: 10 additions & 1 deletion scripts/utils.py → scripts/translate_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import math
import os
import shutil
import yaml

ASSET_FOLDER_MAPPING = {
Expand Down Expand Up @@ -130,9 +132,16 @@ def compile_translations(root_path):
print(f"Writing all translations out to {out_path}")
with open(out_path, 'w') as outfile:
outfile.write("---\n")
yaml.safe_dump(all_translations, outfile)
# If we don't use an extremely large width, the jinja in our translations
# can be broken by newlines. So we use the largest number there is.
yaml.dump(all_translations, outfile, width=math.inf)
outfile.write("\n{{ patch('superset-extra-asset-translations')}}\n")

# We remove these files to avoid confusion about where translations are coming
# from, and because otherwise we will need to re-save them with the large
# width as above to avoid Jinja parsing errors.
print("Removing downloaded translations files... ")
shutil.rmtree(translations_path)


def extract_translations(root_path):
Expand Down

This file was deleted.

Loading

0 comments on commit ff1115a

Please sign in to comment.