Repository: getnikola/nikola

Issue:
Post in multiple languages, but not in DEFAULT_LANG, leads to error
### Environment (if reporting a bug)

**Nikola Version:** `master`

### Description:

If I follow the instructions in #2956, but enter languages `en,es,de`, and copy `posts/test.es.rst` also to `posts/test.de.rst`, I get another error (or rather, a bunch of them):

```
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate posts/test/index.html: posts/test.es.rst and posts/test.de.rst
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate posts/test/index.rst: posts/test.es.rst and posts/test.de.rst
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate es/posts/test/index.html: posts/test.es.rst and posts/test.de.rst
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate es/posts/test/index.rst: posts/test.es.rst and posts/test.de.rst
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate de/posts/test/index.html: posts/test.es.rst and posts/test.de.rst
[2018-05-04T20:24:51Z] ERROR: Nikola: Two posts are trying to generate de/posts/test/index.rst: posts/test.es.rst and posts/test.de.rst
```



Discussion:

Resolving patch:
diff --git a/nikola/plugins/misc/scan_posts.py b/nikola/plugins/misc/scan_posts.py
--- a/nikola/plugins/misc/scan_posts.py
+++ b/nikola/plugins/misc/scan_posts.py
@@ -83,11 +83,9 @@ def scan(self):
                              if not any([x.startswith('.')
                                          for x in p.split(os.sep)])]
 
-                for base_path in full_list:
+                for base_path in sorted(full_list):
                     if base_path in seen:
                         continue
-                    else:
-                        seen.add(base_path)
                     try:
                         post = Post(
                             base_path,
@@ -100,6 +98,8 @@ def scan(self):
                             destination_base=destination_translatable,
                             metadata_extractors_by=self.site.metadata_extractors_by
                         )
+                        for lang in post.translated_to:
+                            seen.add(post.translated_source_path(lang))
                         timeline.append(post)
                     except Exception:
                         LOGGER.error('Error reading post {}'.format(base_path))
diff --git a/nikola/post.py b/nikola/post.py
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -587,11 +587,10 @@ def _get_dependencies(self, deps_list):
     def deps(self, lang):
         """Return a list of file dependencies to build this post's page."""
         deps = []
-        if self.default_lang in self.translated_to:
-            deps.append(self.base_path)
-            deps.append(self.source_path)
-            if os.path.exists(self.metadata_path):
-                deps.append(self.metadata_path)
+        deps.append(self.base_path)
+        deps.append(self.source_path)
+        if os.path.exists(self.metadata_path):
+            deps.append(self.metadata_path)
         if lang != self.default_lang:
             cand_1 = get_translation_candidate(self.config, self.source_path, lang)
             cand_2 = get_translation_candidate(self.config, self.base_path, lang)


Test patch: