Permalink
Browse files

Fix more places without proper language support.

  • Loading branch information...
1 parent 0215e3f commit 07233e046c324f4aa4ca427dbbb4d24e78e39ec9 @ericholscher ericholscher committed Mar 19, 2013
@@ -298,6 +298,9 @@ def serve_docs(request, lang_slug, version_slug, filename, project_slug=None):
filename += "index.html"
else:
filename = filename.rstrip('/')
+ # Use the old paths if we're on our old location.
+ # Otherwise use the new language symlinks.
+ # This can be removed once we have 'en' symlinks for every project.
if lang_slug == proj.language:
basepath = proj.rtd_build_path(version_slug)
else:
@@ -124,11 +124,14 @@
("sl", "Slovenian"),
("sv", "Swedish"),
("tr", "Turkish"),
- ("nb_NO", "Norwegian Bokmal"),
- ("pt_BR", "Brazilian Portuguese"),
- ("uk_UA", "Ukrainian"),
- ("zh_CN", "Simplified Chinese"),
- ("zh_TW", "Traditional Chinese"),
+
+ # Comment out non-2 letter language names for now.
+ # Update this once we're done with the initial cutover.
+ #("nb_NO", "Norwegian Bokmal"),
+ #("pt_BR", "Brazilian Portuguese"),
+ #("uk_UA", "Ukrainian"),
+ #("zh_CN", "Simplified Chinese"),
+ #("zh_TW", "Traditional Chinese"),
)
LANGUAGES_REGEX = "|".join(
@@ -78,7 +78,7 @@ def __unicode__(self):
#HACK
def get_absolute_url(self):
- return "http://%s.readthedocs.org/projects/%s/en/latest/" % (self.parent.slug, self.child.slug)
+ return "http://%s.readthedocs.org/projects/%s/%s/latest/" % (self.parent.slug, self.child.slug, self.child.language)
class Project(models.Model):
#Auto fields
@@ -189,14 +189,16 @@ def save(self, *args, **kwargs):
def get_absolute_url(self):
return reverse('projects_detail', args=[self.slug])
- def get_docs_url(self, version_slug=None, lang_slug='en'):
+ def get_docs_url(self, version_slug=None, lang_slug=None):
"""
Return a url for the docs. Always use http for now,
to avoid content warnings.
"""
protocol = "http"
version = version_slug or self.get_default_version()
use_subdomain = getattr(settings, 'USE_SUBDOMAIN', False)
+ if not lang_slug:
+ lang_slug = self.language
if use_subdomain:
return "%s://%s/%s/%s/" % (
protocol,
@@ -315,7 +317,9 @@ def checkout_path(self, version='latest'):
def venv_path(self, version='latest'):
return os.path.join(self.doc_path, 'envs', version)
- def translations_path(self, language='en'):
+ def translations_path(self, language=None):
+ if not language:
+ language = self.language
return os.path.join(self.doc_path, 'translations', language)
def venv_bin(self, version='latest', bin='python'):
@@ -559,7 +563,7 @@ class ImportedFile(models.Model):
@models.permalink
def get_absolute_url(self):
- return ('docs_detail', [self.project.slug, 'en', self.version.slug, self.path])
+ return ('docs_detail', [self.project.slug, self.project.language, self.version.slug, self.path])
def __unicode__(self):
return '%s: %s' % (self.name, self.project)
@@ -587,6 +587,13 @@ def symlink_translations(version):
log.info("Symlinking %s" % translation.language)
run_on_app_servers('mkdir -p %s' % '/'.join(base_path.split('/')[:-1]))
run_on_app_servers('ln -nsf %s %s' % (translation_dir, base_path))
+ # Hack in the en version for backwards compat
+ base_path = version.project.translations_path('en')
+ translation_dir = version.project.rtd_build_path(version.project.slug)
+ # Chop off the version from the end.
+ translation_dir = '/'.join(translation_dir.split('/')[:-1])
+ run_on_app_servers('mkdir -p %s' % '/'.join(base_path.split('/')[:-1]))
+ run_on_app_servers('ln -nsf %s %s' % (translation_dir, base_path))
def send_notifications(version, build):
zenircbot_notification(version.id)

0 comments on commit 07233e0

Please sign in to comment.