Commit 3b9650d8 authored by Pat David's avatar Pat David
Browse files

Hacking and testing translation links an sub-site stuff again

parent 46b52773
......@@ -15,7 +15,9 @@ I (Pat David) am creating this page to keep notes and information for building/m
* [Using Pelican](./using-pelican/)
* [Markdown Cheatsheet](./markdown.html)
* [Edit the Front Page]({filename}./frontpage.md)
* [Translations]({filename}./translating.fr.md)
* [Translations]({filename}./translating.fr.md)
[fr → en Test Link](./translating.html)
Le travail que je fais ici est basée sur un couple de suggestions de la dernière année (ou plus, je suis sûr) pour actualiser la conception de WGO. En particulier, je l'avais créé une brève maquette pour montrer et ai été d'utiliser cela comme une sorte de guide visuel pour approcher la page principale. Vous pouvez voir que maquette .PNG ici (~ 1.8MB), ou un petit aperçu:
......
......@@ -16,6 +16,8 @@ I (Pat David) am creating this page to keep notes and information for building/m
* [Edit the Front Page]({filename}./frontpage.md)
* [Translations]({filename}./translating.md)
[en → fr Test Link](./translating.html)
The work I am doing here is based on a couple of suggestions over the past year (or more, I'm sure) to refresh the design of WGO.
In particular, I had created a brief mockup to show and have been using that as a sort of visual guide for approaching the main page.
You can view that [mockup .PNG here](/images/mockup3.png) (~1.8MB), or a smaller preview:
......
......@@ -63,3 +63,15 @@ Et ainsi de suite pour chaque traduction.
### Fallback
Une fonctionnalité intéressante du plugin i18n_subsites est que les pages qui sont liées, mais le manque d'une traduction, seront toujours montrer la version **en** comme solution de repli.
* [A better link to meta](/about/meta/) `[A better link to meta](/about/meta/)`
Leads back to english version of the site from everywhere.
* [<del>A better link to meta</del>](./about/meta/) `[A better link to meta](./about/meta/)`
Doesn't work right (as expected).
* [A better link to meta](../../about/meta/) `[A better link to meta](../../about/meta/)`
Leads to the translated version of the page correctly!
* [A better link to meta](../meta/) `[A better link to meta](../meta/)`
Also leads back to translated version of the page correctly.
* [A better link to meta](./) `[A better link to meta](./)`
Also leads back to translated version of the page correctly.
......@@ -71,3 +71,48 @@ And so on for each translation.
### Fallback
A nice feature of the i18n_subsites plugin is that pages that are linked, but lack a translation, will still show the **en** version as a fallback.
### I Can't Believe That Worked...
So I had to hack at the `mimic_hierarchy` plugin again to fix one piece of small weirdness with i18n_subsites.
The problem was that if you had a file, and it's translation:
/about/meta/index.md
/about/meta/index.fr.md
Then the path/files that get created with i18n look like this, respectively:
gimp.org/about/meta/index.html
gimp.org/fr/about/meta/index.fr.html
Which is _less_ than ideal. The reason is that if I wanted to get to the first instance with a pretty url, I could go to:
gimp.org/about/meta/
Likewise, linking to that page internally could be done easily through either `{filename}` to the pre-rendered file:
[A link to meta]({filename}../../about/meta/index.md)
Which would render this: [A link to meta]({filename}../../about/meta/index.md)
The problem with using this link is that if it is called from a translated page, it will cause it to lead back to the **en** version of the page.
A better solution would be to allow internal links to simply point to locations directly without having to worry about the sub-site.
Some different link types to test:
* [A better link to meta](/about/meta/) `[A better link to meta](/about/meta/)`
Leads back to english version of the site from everywhere.
* [<del>A better link to meta</del>](./about/meta/) `[A better link to meta](./about/meta/)`
Doesn't work right (as expected).
* [A better link to meta](../../about/meta/) `[A better link to meta](../../about/meta/)`
Leads to the translated version of the page correctly!
* [A better link to meta](../meta/) `[A better link to meta](../meta/)`
Also leads back to translated version of the page correctly.
* [A better link to meta](./) `[A better link to meta](./)`
Also leads back to translated version of the page correctly.
At the moment, we basically need to use relative links to the output files, which will then work no matter what the translation is it's used from.
The other option is to continue using direct linking to files pre-rendering, as in the Pelican manual (and above).
The writer just needs to be careful to link to the correct place when doing this.
......@@ -71,9 +71,9 @@ def mimic_page_hierarchy(content_object):
metadata['filename'] = fn.replace('fr.', '')
print("#### filename: " + metadata['filename'] )
if 'index' in metadata['filename'] and 'about/meta' in metadata['slug']:
print('slug: ' + metadata['slug'] + ' filename: ' + metadata['filename'] )
#print("#### filename: " + metadata['filename'] )
#if 'index' in metadata['filename'] and 'about/meta' in metadata['slug']:
#print('slug: ' + metadata['slug'] + ' filename: ' + metadata['filename'] )
# PLD: this is my doing, sorry...
# ok, if path is empty, use page.slug
......@@ -106,9 +106,9 @@ def mimic_page_hierarchy(content_object):
# We have to account for non-default language and format either,
# e.g., PAGE_SAVE_AS or PAGE_LANG_SAVE_AS
infix = '' if in_default_lang(page) else 'LANG_'
if 'index' in metadata['filename'] and 'about/meta' in metadata['slug']:
print( "infix: " + infix + " key: " + key.upper() )
print( "RETURNING: " + page.settings['PAGE_' + infix + key.upper()].format(**metadata) )
#if 'index' in metadata['filename'] and 'about/meta' in metadata['slug']:
#print( "infix: " + infix + " key: " + key.upper() )
#print( "RETURNING: " + page.settings['PAGE_' + infix + key.upper()].format(**metadata) )
return page.settings['PAGE_' + infix + key.upper()].format(**metadata)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment