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

Chapter slugs and image directories based on title so don't work for Translations #654

Closed
tunetheweb opened this issue Jan 30, 2020 · 1 comment · Fixed by #683
Closed
Labels
bug Something isn't working development Building the Almanac tech stack translation world wide web

Comments

@tunetheweb
Copy link
Member

tunetheweb commented Jan 30, 2020

main.py has the following:

def get_chapter_slug(metadata):
title = metadata.get('title')
return title.lower().replace(' ', '-').replace('/', '')
def get_chapter_image_dir(metadata):
title = metadata.get('title', 'NO TITLE FOUND').replace('/', '_').replace(' ', '_')
return '%.2d_%s' % (metadata.get('chapter_number', 0), title)

This means we use the chapter title from the meta data to get the chapter slug (for the ToC) and the chapter image directory (for the chapter hero images and figures).

This does not work if we translate the title as @borisschapira has done for #652 and @SilentJMA did for #539

I think we should change these two functions to be based on either:

  1. The md or html filename (ideally at chapter generation so we're not dependent on doing this at runtime and being dependent on the URL which is user supplied data so shouldn't be trusted - at least without verification).
  2. The config - but not sure how to map this (based on the part and chapter number from the meta data?).

I know we've talked about a larger restructure of the config in #561 and even changing how the chapters are generated completely in #634 but we don't seem to be making progress on those so think we need to do something in the short term to address this issue as it prevents viewing the chapters with images in another language (for checking PRs in dev) and will obviously prevent going live with any translations in prod.

@mikegeyser any thoughts?

@tunetheweb tunetheweb added bug Something isn't working development Building the Almanac tech stack translation world wide web labels Jan 30, 2020
@borisschapira
Copy link
Contributor

My 2 cents: extrapolating the slug from the filename, and using it to build the dirname are common practices in the SSG world, so this seems ok for me, rather that using the translated title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working development Building the Almanac tech stack translation world wide web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants