From 91ec0f93c74161273eb52d3d49b56de79eb118ed Mon Sep 17 00:00:00 2001 From: mimu Date: Sat, 12 Oct 2013 10:47:00 +0900 Subject: [PATCH] Fixed create draft article with translations #Ref 1107 --- pelican/generators.py | 6 +- .../basic/drafts/second-article-fr.html | 70 +++++++++++ .../draft-article-with-translation-ja.html | 99 +++++++++++++++ .../draft-article-with-translation.html | 100 +++++++++++++++ .../output/custom/drafts/oh-yeah-fr.html | 114 ++++++++++++++++++ .../custom/drafts/second-article-fr.html | 114 ++++++++++++++++++ .../draft_article_with_translation-ja.rst | 8 ++ .../draft_article_with_translation.rst | 8 ++ 8 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 pelican/tests/output/basic/drafts/second-article-fr.html create mode 100644 pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html create mode 100644 pelican/tests/output/custom/drafts/draft-article-with-translation.html create mode 100644 pelican/tests/output/custom/drafts/oh-yeah-fr.html create mode 100644 pelican/tests/output/custom/drafts/second-article-fr.html create mode 100644 samples/content/draft_article_with_translation-ja.rst create mode 100644 samples/content/draft_article_with_translation.rst diff --git a/pelican/generators.py b/pelican/generators.py index d703c6cb..1015122d 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -354,7 +354,11 @@ class ArticlesGenerator(Generator): def generate_drafts(self, write): """Generate drafts pages.""" for article in chain(self.translations, self.drafts): - write(os.path.join('drafts', article.save_as), + filename = article.save_as + if article.lang != self.settings["DEFAULT_LANG"]: + filename + "."+article.lang + + write(os.path.join('drafts', filename), self.get_template(article.template), self.context, article=article, category=article.category, all_articles=self.articles) diff --git a/pelican/tests/output/basic/drafts/second-article-fr.html b/pelican/tests/output/basic/drafts/second-article-fr.html new file mode 100644 index 00000000..050d49b3 --- /dev/null +++ b/pelican/tests/output/basic/drafts/second-article-fr.html @@ -0,0 +1,70 @@ + + + + + Deuxième article + + + + + + + + +
+ +
+
+ +
+ + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html new file mode 100644 index 00000000..f2f6737d --- /dev/null +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation-ja.html @@ -0,0 +1,99 @@ + + + + + 他言語の下書きテスト + + + + + + + + + +Fork me on GitHub + + +
+ +
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/draft-article-with-translation.html b/pelican/tests/output/custom/drafts/draft-article-with-translation.html new file mode 100644 index 00000000..2f5fb9b9 --- /dev/null +++ b/pelican/tests/output/custom/drafts/draft-article-with-translation.html @@ -0,0 +1,100 @@ + + + + + A draft article with translation + + + + + + + + + +Fork me on GitHub + + +
+ +
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/oh-yeah-fr.html b/pelican/tests/output/custom/drafts/oh-yeah-fr.html new file mode 100644 index 00000000..1bad0d85 --- /dev/null +++ b/pelican/tests/output/custom/drafts/oh-yeah-fr.html @@ -0,0 +1,114 @@ + + + + + Trop bien ! + + + + + + + + + +Fork me on GitHub + + +
+
+
+

+ Trop bien !

+
+ +
+

Et voila du contenu en français

+ +
+
+

Comments !

+
+ +
+ +
+
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/pelican/tests/output/custom/drafts/second-article-fr.html b/pelican/tests/output/custom/drafts/second-article-fr.html new file mode 100644 index 00000000..21467c59 --- /dev/null +++ b/pelican/tests/output/custom/drafts/second-article-fr.html @@ -0,0 +1,114 @@ + + + + + Deuxième article + + + + + + + + + +Fork me on GitHub + + +
+
+
+

+ Deuxième article

+
+ +
+

Ceci est un article, en français.

+ +
+
+

Comments !

+
+ +
+ +
+
+
+
+

blogroll

+ +
+ +
+ + + + + + \ No newline at end of file diff --git a/samples/content/draft_article_with_translation-ja.rst b/samples/content/draft_article_with_translation-ja.rst new file mode 100644 index 00000000..f22bfbbe --- /dev/null +++ b/samples/content/draft_article_with_translation-ja.rst @@ -0,0 +1,8 @@ +他言語の下書きテスト +###################### + +:slug: draft-article-with-translation +:status: draft +:lang: ja + +これは下書きファイルです。/draftに生成されて、他のところには影響を与えません。 diff --git a/samples/content/draft_article_with_translation.rst b/samples/content/draft_article_with_translation.rst new file mode 100644 index 00000000..5bd83dbb --- /dev/null +++ b/samples/content/draft_article_with_translation.rst @@ -0,0 +1,8 @@ +A draft article with translation +################################ + +:slug: draft-article-with-translation +:status: draft + +This is a draft article, it should live under the /drafts/ folder and not be +listed anywhere else.