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

Side by Side Diff: cms/utils.py

Issue 5242593268989952: Issue 2340 - Don`t generate pages if less than 30% have been translated (Closed)
Patch Set: Don`t link to pages that don`t exist Created May 6, 2015, 3:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« cms/sources.py ('K') | « cms/sources.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 raise Exception("Page %s uses unknown format %s" % (page, format)) 52 raise Exception("Page %s uses unknown format %s" % (page, format))
53 53
54 # Note: The converter might change some parameters so we can only read in 54 # Note: The converter might change some parameters so we can only read in
55 # template data here. 55 # template data here.
56 params["templatedata"] = source.read_template(params["template"]) 56 params["templatedata"] = source.read_template(params["template"])
57 57
58 defaultlocale = params["config"].get("general", "defaultlocale") 58 defaultlocale = params["config"].get("general", "defaultlocale")
59 params["defaultlocale"] = defaultlocale 59 params["defaultlocale"] = defaultlocale
60 60
61 locales = [ 61 locales = [
62 locale 62 l
Sebastian Noack 2015/05/06 16:15:30 Why didn't you keep the more descriptive variable
Wladimir Palant 2015/05/06 17:21:59 Please see http://codereview.adblockplus.org/52425
63 for locale in source.list_locales() 63 for l in source.list_locales()
64 if source.has_locale(locale, localefile) 64 if source.has_locale(locale, localefile)
65 ] 65 ]
66 if defaultlocale not in locales: 66 if defaultlocale not in locales:
67 locales.append(defaultlocale) 67 locales.append(defaultlocale)
68 locales.sort() 68 locales.sort()
69 params["available_locales"] = locales 69 params["available_locales"] = locales
70 70
71 params["head"], params["body"] = converter() 71 params["head"], params["body"] = converter()
72 if converter.total_translations > 0:
73 params["translation_ratio"] = (1 -
74 float(converter.missing_translations) / converter.total_translations)
75 else:
76 params["translation_ratio"] = 1
77
72 return params 78 return params
73 79
74 def process_page(source, locale, page, format, site_url_override=None): 80 def process_page(source, locale, page, format=None, site_url_override=None):
75 return TemplateConverter( 81 return TemplateConverter(
76 get_page_params(source, locale, page, format, site_url_override), 82 get_page_params(source, locale, page, format, site_url_override),
77 key="templatedata" 83 key="templatedata"
78 )() 84 )()
OLDNEW
« cms/sources.py ('K') | « cms/sources.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld