Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/bin/generate_static_pages.py

Issue 5242593268989952: Issue 2340 - Don`t generate pages if less than 30% have been translated (Closed)
Patch Set: Created April 17, 2015, 5:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cms/converters.py » ('j') | cms/utils.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cms/bin/generate_static_pages.py
===================================================================
--- a/cms/bin/generate_static_pages.py
+++ b/cms/bin/generate_static_pages.py
@@ -14,16 +14,18 @@
#
# You should have received a copy of the GNU General Public License
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
import sys, os, re, errno, codecs
from ..utils import process_page
from ..sources import MercurialSource
+MIN_TRANSLATED = 0.3
Sebastian Noack 2015/04/17 17:32:27 Is this actually the same threshold we currently u
Wladimir Palant 2015/04/17 18:21:15 Yes. The effect might still be different however,
+
def memoize(func):
memoized = {}
def wrapper(*args):
try:
return memoized[args]
except KeyError:
return memoized.setdefault(args, func(*args))
return wrapper
@@ -65,24 +67,25 @@ def generate_pages(repo, output_dir):
config = source.read_config()
defaultlocale = config.get("general", "defaultlocale")
locales = list(source.list_locales())
if defaultlocale not in locales:
locales.append(defaultlocale)
for page, format in source.list_pages():
for locale in locales:
if locale == defaultlocale or source.has_locale(locale, page):
- pagedata = process_page(source, locale, page, format)
+ pagedata = process_page(source, locale, page, format,
+ min_translated=MIN_TRANSLATED)
+ if pagedata:
+ # Make sure links to static files are versioned
+ pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
+ pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
+ pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
- # Make sure links to static files are versioned
- pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
- pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
- pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata)
-
- write_file([locale] + page.split("/"), pagedata)
+ write_file([locale] + page.split("/"), pagedata)
for filename in source.list_localizable_files():
for locale in locales:
if source.has_localizable_file(locale, filename):
filedata = source.read_localizable_file(locale, filename)
write_file([locale] + filename.split("/"), filedata, binary=True)
for filename in source.list_static():
« no previous file with comments | « no previous file | cms/converters.py » ('j') | cms/utils.py » ('J')

Powered by Google App Engine
This is Rietveld