[gimp-web/gimp-web-static] Hacking and testing translation links an sub-site stuff again



commit 3b9650d873e1c99f99a25c4778bf3a52604fca60
Author: Pat David <patdavid gmail com>
Date:   Fri Aug 21 17:47:06 2015 -0500

    Hacking and testing translation links an sub-site stuff again

 content/about/meta/index.fr.md             |    4 ++-
 content/about/meta/index.md                |    2 +
 content/about/meta/translating.fr.md       |   12 +++++++
 content/about/meta/translating.md          |   45 ++++++++++++++++++++++++++++
 plugins/mimic_hierarchy/mimic_hierarchy.py |   12 ++++----
 5 files changed, 68 insertions(+), 7 deletions(-)
---
diff --git a/content/about/meta/index.fr.md b/content/about/meta/index.fr.md
index b6c4d0a..e9050ca 100644
--- a/content/about/meta/index.fr.md
+++ b/content/about/meta/index.fr.md
@@ -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 &rarr; 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:
 
diff --git a/content/about/meta/index.md b/content/about/meta/index.md
index 91cef4d..1c6588a 100644
--- a/content/about/meta/index.md
+++ b/content/about/meta/index.md
@@ -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 &rarr; 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:
diff --git a/content/about/meta/translating.fr.md b/content/about/meta/translating.fr.md
index b54b900..44fb6f3 100644
--- a/content/about/meta/translating.fr.md
+++ b/content/about/meta/translating.fr.md
@@ -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.
diff --git a/content/about/meta/translating.md b/content/about/meta/translating.md
index 43766de..cc23d86 100644
--- a/content/about/meta/translating.md
+++ b/content/about/meta/translating.md
@@ -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.
diff --git a/plugins/mimic_hierarchy/mimic_hierarchy.py b/plugins/mimic_hierarchy/mimic_hierarchy.py
index 88479be..6489f85 100644
--- a/plugins/mimic_hierarchy/mimic_hierarchy.py
+++ b/plugins/mimic_hierarchy/mimic_hierarchy.py
@@ -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)
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]