We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
SHOW_UNTRANSLATED_POSTS=False leads to 404s in archives
Even though SHOW_UNTRANSLATED_POSTS=False, archives still display posts that do not exist, leading to 404s everywhere.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nikola/plugins/task/archive.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright © 2012-2014 Roberto Alsina and others.
4 
5 # Permission is hereby granted, free of charge, to any
6 # person obtaining a copy of this software and associated
7 # documentation files (the "Software"), to deal in the
8 # Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the
11 # Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
13 #
14 # The above copyright notice and this permission notice
15 # shall be included in all copies or substantial portions of
16 # the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
22 # OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 
27 import os
28 
29 # for tearDown with _reload we cannot use 'import from' to access LocaleBorg
30 import nikola.utils
31 from nikola.plugin_categories import Task
32 from nikola.utils import config_changed
33 
34 
35 class Archive(Task):
36     """Render the post archives."""
37 
38     name = "render_archive"
39 
40     def set_site(self, site):
41         site.register_path_handler('archive', self.archive_path)
42         return super(Archive, self).set_site(site)
43 
44     def _prepare_task(self, kw, name, lang, posts, items, template_name,
45                       title, deps_translatable=None):
46         # name: used to build permalink and destination
47         # posts, items: posts or items; only one of them should be used,
48         #               the other be None
49         # template_name: name of the template to use
50         # title: the (translated) title for the generated page
51         # deps_translatable: dependencies (None if not added)
52         assert posts is not None or items is not None
53 
54         context = {}
55         context["lang"] = lang
56         context["title"] = title
57         context["permalink"] = self.site.link("archive", name, lang)
58         if posts is not None:
59             context["posts"] = posts
60             n = len(posts)
61         else:
62             context["items"] = items
63             n = len(items)
64         task = self.site.generic_post_list_renderer(
65             lang,
66             [],
67             os.path.join(kw['output_folder'], self.site.path("archive", name, lang)),
68             template_name,
69             kw['filters'],
70             context,
71         )
72 
73         task_cfg = {1: task['uptodate'][0].config, 2: kw, 3: n}
74         if deps_translatable is not None:
75             task_cfg[4] = deps_translatable
76         task['uptodate'] = [config_changed(task_cfg)]
77         task['basename'] = self.name
78         return task
79 
80     def _generate_posts_task(self, kw, name, lang, posts, title, deps_translatable=None):
81         posts = sorted(posts, key=lambda a: a.date)
82         posts.reverse()
83         yield self._prepare_task(kw, name, lang, posts, None, "list_post.tmpl", title, deps_translatable)
84 
85     def gen_tasks(self):
86         kw = {
87             "messages": self.site.MESSAGES,
88             "translations": self.site.config['TRANSLATIONS'],
89             "output_folder": self.site.config['OUTPUT_FOLDER'],
90             "filters": self.site.config['FILTERS'],
91             "create_monthly_archive": self.site.config['CREATE_MONTHLY_ARCHIVE'],
92             "create_single_archive": self.site.config['CREATE_SINGLE_ARCHIVE'],
93             "create_full_archives": self.site.config['CREATE_FULL_ARCHIVES'],
94             "create_daily_archive": self.site.config['CREATE_DAILY_ARCHIVE'],
95         }
96         self.site.scan_posts()
97         yield self.group_task()
98         # TODO add next/prev links for years
99         if (kw['create_monthly_archive'] and kw['create_single_archive']) and not kw['create_full_archives']:
100             raise Exception('Cannot create monthly and single archives at the same time.')
101         for lang in kw["translations"]:
102             if kw['create_single_archive'] and not kw['create_full_archives']:
103                 # if we are creating one single archive
104                 archdata = {}
105             else:
106                 # if we are not creating one single archive, start with all years
107                 archdata = self.site.posts_per_year.copy()
108             if kw['create_single_archive'] or kw['create_full_archives']:
109                 # if we are creating one single archive, or full archives
110                 archdata[None] = self.site.posts  # for create_single_archive
111 
112             for year, posts in archdata.items():
113                 # Add archive per year or total archive
114                 if year:
115                     title = kw["messages"][lang]["Posts for year %s"] % year
116                 else:
117                     title = kw["messages"][lang]["Archive"]
118                 deps_translatable = {}
119                 for k in self.site._GLOBAL_CONTEXT_TRANSLATABLE:
120                     deps_translatable[k] = self.site.GLOBAL_CONTEXT[k](lang)
121                 if not kw["create_monthly_archive"] or kw["create_full_archives"]:
122                     yield self._generate_posts_task(kw, year, lang, posts, title, deps_translatable)
123                 else:
124                     months = set([(m.split('/')[1], self.site.link("archive", m, lang)) for m in self.site.posts_per_month.keys() if m.startswith(str(year))])
125                     months = sorted(list(months))
126                     months.reverse()
127                     items = [[nikola.utils.LocaleBorg().get_month_name(int(month), lang), link] for month, link in months]
128                     yield self._prepare_task(kw, year, lang, None, items, "list.tmpl", title, deps_translatable)
129 
130             if not kw["create_monthly_archive"] and not kw["create_full_archives"] and not kw["create_daily_archive"]:
131                 continue  # Just to avoid nesting the other loop in this if
132             for yearmonth, posts in self.site.posts_per_month.items():
133                 # Add archive per month
134                 year, month = yearmonth.split('/')
135                 if kw["create_monthly_archive"] or kw["create_full_archives"]:
136                     title = kw["messages"][lang]["Posts for {month} {year}"].format(
137                         year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang))
138                     yield self._generate_posts_task(kw, yearmonth, lang, posts, title)
139 
140                 if not kw["create_full_archives"] and not kw["create_daily_archive"]:
141                     continue  # Just to avoid nesting the other loop in this if
142                 # Add archive per day
143                 days = dict()
144                 for p in posts:
145                     if p.date.day not in days:
146                         days[p.date.day] = list()
147                     days[p.date.day].append(p)
148                 for day, posts in days.items():
149                     title = kw["messages"][lang]["Posts for {month} {day}, {year}"].format(
150                         year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang), day=day)
151                     yield self._generate_posts_task(kw, yearmonth + '/{0:02d}'.format(day), lang, posts, title)
152 
153         if not kw['create_single_archive'] and not kw['create_full_archives']:
154             # And an "all your years" page for yearly and monthly archives
155             years = list(self.site.posts_per_year.keys())
156             years.sort(reverse=True)
157             kw['years'] = years
158             for lang in kw["translations"]:
159                 items = [(y, self.site.link("archive", y, lang)) for y in years]
160                 yield self._prepare_task(kw, None, lang, None, items, "list.tmpl", kw["messages"][lang]["Archive"])
161 
162     def archive_path(self, name, lang):
163         if name:
164             return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
165                                   self.site.config['ARCHIVE_PATH'], name,
166                                   self.site.config['INDEX_FILE']] if _f]
167         else:
168             return [_f for _f in [self.site.config['TRANSLATIONS'][lang],
169                                   self.site.config['ARCHIVE_PATH'],
170                                   self.site.config['ARCHIVE_FILENAME']] if _f]
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nikola/plugins/task/archive.py b/nikola/plugins/task/archive.py
--- a/nikola/plugins/task/archive.py
+++ b/nikola/plugins/task/archive.py
@@ -90,6 +90,7 @@
             "filters": self.site.config['FILTERS'],
             "create_monthly_archive": self.site.config['CREATE_MONTHLY_ARCHIVE'],
             "create_single_archive": self.site.config['CREATE_SINGLE_ARCHIVE'],
+            "show_untranslated_posts": self.site.config['SHOW_UNTRANSLATED_POSTS'],
             "create_full_archives": self.site.config['CREATE_FULL_ARCHIVES'],
             "create_daily_archive": self.site.config['CREATE_DAILY_ARCHIVE'],
         }
@@ -109,6 +110,11 @@
                 # if we are creating one single archive, or full archives
                 archdata[None] = self.site.posts  # for create_single_archive
 
+            # Filter untranslated posts (Issue #1360)
+            if not kw["show_untranslated_posts"]:
+                for year, posts in archdata.items():
+                    archdata[year] = [p for p in posts if lang in p.translated_to]
+
             for year, posts in archdata.items():
                 # Add archive per year or total archive
                 if year:

{"golden_diff": "diff --git a/nikola/plugins/task/archive.py b/nikola/plugins/task/archive.py\n--- a/nikola/plugins/task/archive.py\n+++ b/nikola/plugins/task/archive.py\n@@ -90,6 +90,7 @@\n             \"filters\": self.site.config['FILTERS'],\n             \"create_monthly_archive\": self.site.config['CREATE_MONTHLY_ARCHIVE'],\n             \"create_single_archive\": self.site.config['CREATE_SINGLE_ARCHIVE'],\n+            \"show_untranslated_posts\": self.site.config['SHOW_UNTRANSLATED_POSTS'],\n             \"create_full_archives\": self.site.config['CREATE_FULL_ARCHIVES'],\n             \"create_daily_archive\": self.site.config['CREATE_DAILY_ARCHIVE'],\n         }\n@@ -109,6 +110,11 @@\n                 # if we are creating one single archive, or full archives\n                 archdata[None] = self.site.posts  # for create_single_archive\n \n+            # Filter untranslated posts (Issue #1360)\n+            if not kw[\"show_untranslated_posts\"]:\n+                for year, posts in archdata.items():\n+                    archdata[year] = [p for p in posts if lang in p.translated_to]\n+\n             for year, posts in archdata.items():\n                 # Add archive per year or total archive\n                 if year:\n", "issue": "SHOW_UNTRANSLATED_POSTS=False leads to 404s in archives\nEven though SHOW_UNTRANSLATED_POSTS=False, archives still display posts that do not exist, leading to 404s everywhere.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2014 Roberto Alsina and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nimport os\n\n# for tearDown with _reload we cannot use 'import from' to access LocaleBorg\nimport nikola.utils\nfrom nikola.plugin_categories import Task\nfrom nikola.utils import config_changed\n\n\nclass Archive(Task):\n    \"\"\"Render the post archives.\"\"\"\n\n    name = \"render_archive\"\n\n    def set_site(self, site):\n        site.register_path_handler('archive', self.archive_path)\n        return super(Archive, self).set_site(site)\n\n    def _prepare_task(self, kw, name, lang, posts, items, template_name,\n                      title, deps_translatable=None):\n        # name: used to build permalink and destination\n        # posts, items: posts or items; only one of them should be used,\n        #               the other be None\n        # template_name: name of the template to use\n        # title: the (translated) title for the generated page\n        # deps_translatable: dependencies (None if not added)\n        assert posts is not None or items is not None\n\n        context = {}\n        context[\"lang\"] = lang\n        context[\"title\"] = title\n        context[\"permalink\"] = self.site.link(\"archive\", name, lang)\n        if posts is not None:\n            context[\"posts\"] = posts\n            n = len(posts)\n        else:\n            context[\"items\"] = items\n            n = len(items)\n        task = self.site.generic_post_list_renderer(\n            lang,\n            [],\n            os.path.join(kw['output_folder'], self.site.path(\"archive\", name, lang)),\n            template_name,\n            kw['filters'],\n            context,\n        )\n\n        task_cfg = {1: task['uptodate'][0].config, 2: kw, 3: n}\n        if deps_translatable is not None:\n            task_cfg[4] = deps_translatable\n        task['uptodate'] = [config_changed(task_cfg)]\n        task['basename'] = self.name\n        return task\n\n    def _generate_posts_task(self, kw, name, lang, posts, title, deps_translatable=None):\n        posts = sorted(posts, key=lambda a: a.date)\n        posts.reverse()\n        yield self._prepare_task(kw, name, lang, posts, None, \"list_post.tmpl\", title, deps_translatable)\n\n    def gen_tasks(self):\n        kw = {\n            \"messages\": self.site.MESSAGES,\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n            \"create_monthly_archive\": self.site.config['CREATE_MONTHLY_ARCHIVE'],\n            \"create_single_archive\": self.site.config['CREATE_SINGLE_ARCHIVE'],\n            \"create_full_archives\": self.site.config['CREATE_FULL_ARCHIVES'],\n            \"create_daily_archive\": self.site.config['CREATE_DAILY_ARCHIVE'],\n        }\n        self.site.scan_posts()\n        yield self.group_task()\n        # TODO add next/prev links for years\n        if (kw['create_monthly_archive'] and kw['create_single_archive']) and not kw['create_full_archives']:\n            raise Exception('Cannot create monthly and single archives at the same time.')\n        for lang in kw[\"translations\"]:\n            if kw['create_single_archive'] and not kw['create_full_archives']:\n                # if we are creating one single archive\n                archdata = {}\n            else:\n                # if we are not creating one single archive, start with all years\n                archdata = self.site.posts_per_year.copy()\n            if kw['create_single_archive'] or kw['create_full_archives']:\n                # if we are creating one single archive, or full archives\n                archdata[None] = self.site.posts  # for create_single_archive\n\n            for year, posts in archdata.items():\n                # Add archive per year or total archive\n                if year:\n                    title = kw[\"messages\"][lang][\"Posts for year %s\"] % year\n                else:\n                    title = kw[\"messages\"][lang][\"Archive\"]\n                deps_translatable = {}\n                for k in self.site._GLOBAL_CONTEXT_TRANSLATABLE:\n                    deps_translatable[k] = self.site.GLOBAL_CONTEXT[k](lang)\n                if not kw[\"create_monthly_archive\"] or kw[\"create_full_archives\"]:\n                    yield self._generate_posts_task(kw, year, lang, posts, title, deps_translatable)\n                else:\n                    months = set([(m.split('/')[1], self.site.link(\"archive\", m, lang)) for m in self.site.posts_per_month.keys() if m.startswith(str(year))])\n                    months = sorted(list(months))\n                    months.reverse()\n                    items = [[nikola.utils.LocaleBorg().get_month_name(int(month), lang), link] for month, link in months]\n                    yield self._prepare_task(kw, year, lang, None, items, \"list.tmpl\", title, deps_translatable)\n\n            if not kw[\"create_monthly_archive\"] and not kw[\"create_full_archives\"] and not kw[\"create_daily_archive\"]:\n                continue  # Just to avoid nesting the other loop in this if\n            for yearmonth, posts in self.site.posts_per_month.items():\n                # Add archive per month\n                year, month = yearmonth.split('/')\n                if kw[\"create_monthly_archive\"] or kw[\"create_full_archives\"]:\n                    title = kw[\"messages\"][lang][\"Posts for {month} {year}\"].format(\n                        year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang))\n                    yield self._generate_posts_task(kw, yearmonth, lang, posts, title)\n\n                if not kw[\"create_full_archives\"] and not kw[\"create_daily_archive\"]:\n                    continue  # Just to avoid nesting the other loop in this if\n                # Add archive per day\n                days = dict()\n                for p in posts:\n                    if p.date.day not in days:\n                        days[p.date.day] = list()\n                    days[p.date.day].append(p)\n                for day, posts in days.items():\n                    title = kw[\"messages\"][lang][\"Posts for {month} {day}, {year}\"].format(\n                        year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang), day=day)\n                    yield self._generate_posts_task(kw, yearmonth + '/{0:02d}'.format(day), lang, posts, title)\n\n        if not kw['create_single_archive'] and not kw['create_full_archives']:\n            # And an \"all your years\" page for yearly and monthly archives\n            years = list(self.site.posts_per_year.keys())\n            years.sort(reverse=True)\n            kw['years'] = years\n            for lang in kw[\"translations\"]:\n                items = [(y, self.site.link(\"archive\", y, lang)) for y in years]\n                yield self._prepare_task(kw, None, lang, None, items, \"list.tmpl\", kw[\"messages\"][lang][\"Archive\"])\n\n    def archive_path(self, name, lang):\n        if name:\n            return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                                  self.site.config['ARCHIVE_PATH'], name,\n                                  self.site.config['INDEX_FILE']] if _f]\n        else:\n            return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                                  self.site.config['ARCHIVE_PATH'],\n                                  self.site.config['ARCHIVE_FILENAME']] if _f]\n", "path": "nikola/plugins/task/archive.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright \u00a9 2012-2014 Roberto Alsina and others.\n\n# Permission is hereby granted, free of charge, to any\n# person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the\n# Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish,\n# distribute, sublicense, and/or sell copies of the\n# Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice\n# shall be included in all copies or substantial portions of\n# the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY\n# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\n# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS\n# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nimport os\n\n# for tearDown with _reload we cannot use 'import from' to access LocaleBorg\nimport nikola.utils\nfrom nikola.plugin_categories import Task\nfrom nikola.utils import config_changed\n\n\nclass Archive(Task):\n    \"\"\"Render the post archives.\"\"\"\n\n    name = \"render_archive\"\n\n    def set_site(self, site):\n        site.register_path_handler('archive', self.archive_path)\n        return super(Archive, self).set_site(site)\n\n    def _prepare_task(self, kw, name, lang, posts, items, template_name,\n                      title, deps_translatable=None):\n        # name: used to build permalink and destination\n        # posts, items: posts or items; only one of them should be used,\n        #               the other be None\n        # template_name: name of the template to use\n        # title: the (translated) title for the generated page\n        # deps_translatable: dependencies (None if not added)\n        assert posts is not None or items is not None\n\n        context = {}\n        context[\"lang\"] = lang\n        context[\"title\"] = title\n        context[\"permalink\"] = self.site.link(\"archive\", name, lang)\n        if posts is not None:\n            context[\"posts\"] = posts\n            n = len(posts)\n        else:\n            context[\"items\"] = items\n            n = len(items)\n        task = self.site.generic_post_list_renderer(\n            lang,\n            [],\n            os.path.join(kw['output_folder'], self.site.path(\"archive\", name, lang)),\n            template_name,\n            kw['filters'],\n            context,\n        )\n\n        task_cfg = {1: task['uptodate'][0].config, 2: kw, 3: n}\n        if deps_translatable is not None:\n            task_cfg[4] = deps_translatable\n        task['uptodate'] = [config_changed(task_cfg)]\n        task['basename'] = self.name\n        return task\n\n    def _generate_posts_task(self, kw, name, lang, posts, title, deps_translatable=None):\n        posts = sorted(posts, key=lambda a: a.date)\n        posts.reverse()\n        yield self._prepare_task(kw, name, lang, posts, None, \"list_post.tmpl\", title, deps_translatable)\n\n    def gen_tasks(self):\n        kw = {\n            \"messages\": self.site.MESSAGES,\n            \"translations\": self.site.config['TRANSLATIONS'],\n            \"output_folder\": self.site.config['OUTPUT_FOLDER'],\n            \"filters\": self.site.config['FILTERS'],\n            \"create_monthly_archive\": self.site.config['CREATE_MONTHLY_ARCHIVE'],\n            \"create_single_archive\": self.site.config['CREATE_SINGLE_ARCHIVE'],\n            \"show_untranslated_posts\": self.site.config['SHOW_UNTRANSLATED_POSTS'],\n            \"create_full_archives\": self.site.config['CREATE_FULL_ARCHIVES'],\n            \"create_daily_archive\": self.site.config['CREATE_DAILY_ARCHIVE'],\n        }\n        self.site.scan_posts()\n        yield self.group_task()\n        # TODO add next/prev links for years\n        if (kw['create_monthly_archive'] and kw['create_single_archive']) and not kw['create_full_archives']:\n            raise Exception('Cannot create monthly and single archives at the same time.')\n        for lang in kw[\"translations\"]:\n            if kw['create_single_archive'] and not kw['create_full_archives']:\n                # if we are creating one single archive\n                archdata = {}\n            else:\n                # if we are not creating one single archive, start with all years\n                archdata = self.site.posts_per_year.copy()\n            if kw['create_single_archive'] or kw['create_full_archives']:\n                # if we are creating one single archive, or full archives\n                archdata[None] = self.site.posts  # for create_single_archive\n\n            # Filter untranslated posts (Issue #1360)\n            if not kw[\"show_untranslated_posts\"]:\n                for year, posts in archdata.items():\n                    archdata[year] = [p for p in posts if lang in p.translated_to]\n\n            for year, posts in archdata.items():\n                # Add archive per year or total archive\n                if year:\n                    title = kw[\"messages\"][lang][\"Posts for year %s\"] % year\n                else:\n                    title = kw[\"messages\"][lang][\"Archive\"]\n                deps_translatable = {}\n                for k in self.site._GLOBAL_CONTEXT_TRANSLATABLE:\n                    deps_translatable[k] = self.site.GLOBAL_CONTEXT[k](lang)\n                if not kw[\"create_monthly_archive\"] or kw[\"create_full_archives\"]:\n                    yield self._generate_posts_task(kw, year, lang, posts, title, deps_translatable)\n                else:\n                    months = set([(m.split('/')[1], self.site.link(\"archive\", m, lang)) for m in self.site.posts_per_month.keys() if m.startswith(str(year))])\n                    months = sorted(list(months))\n                    months.reverse()\n                    items = [[nikola.utils.LocaleBorg().get_month_name(int(month), lang), link] for month, link in months]\n                    yield self._prepare_task(kw, year, lang, None, items, \"list.tmpl\", title, deps_translatable)\n\n            if not kw[\"create_monthly_archive\"] and not kw[\"create_full_archives\"] and not kw[\"create_daily_archive\"]:\n                continue  # Just to avoid nesting the other loop in this if\n            for yearmonth, posts in self.site.posts_per_month.items():\n                # Add archive per month\n                year, month = yearmonth.split('/')\n                if kw[\"create_monthly_archive\"] or kw[\"create_full_archives\"]:\n                    title = kw[\"messages\"][lang][\"Posts for {month} {year}\"].format(\n                        year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang))\n                    yield self._generate_posts_task(kw, yearmonth, lang, posts, title)\n\n                if not kw[\"create_full_archives\"] and not kw[\"create_daily_archive\"]:\n                    continue  # Just to avoid nesting the other loop in this if\n                # Add archive per day\n                days = dict()\n                for p in posts:\n                    if p.date.day not in days:\n                        days[p.date.day] = list()\n                    days[p.date.day].append(p)\n                for day, posts in days.items():\n                    title = kw[\"messages\"][lang][\"Posts for {month} {day}, {year}\"].format(\n                        year=year, month=nikola.utils.LocaleBorg().get_month_name(int(month), lang), day=day)\n                    yield self._generate_posts_task(kw, yearmonth + '/{0:02d}'.format(day), lang, posts, title)\n\n        if not kw['create_single_archive'] and not kw['create_full_archives']:\n            # And an \"all your years\" page for yearly and monthly archives\n            years = list(self.site.posts_per_year.keys())\n            years.sort(reverse=True)\n            kw['years'] = years\n            for lang in kw[\"translations\"]:\n                items = [(y, self.site.link(\"archive\", y, lang)) for y in years]\n                yield self._prepare_task(kw, None, lang, None, items, \"list.tmpl\", kw[\"messages\"][lang][\"Archive\"])\n\n    def archive_path(self, name, lang):\n        if name:\n            return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                                  self.site.config['ARCHIVE_PATH'], name,\n                                  self.site.config['INDEX_FILE']] if _f]\n        else:\n            return [_f for _f in [self.site.config['TRANSLATIONS'][lang],\n                                  self.site.config['ARCHIVE_PATH'],\n                                  self.site.config['ARCHIVE_FILENAME']] if _f]\n", "path": "nikola/plugins/task/archive.py"}]}