зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f73f629e8cca (bug 1517528) on request from jaws, CLOSED TREE.
This commit is contained in:
Родитель
9c5858d0a5
Коммит
1dd267df2b
|
@ -4,7 +4,18 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html [
|
||||
<!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
|
||||
%htmlDTD;
|
||||
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
|
||||
%globalDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
%brandDTD;
|
||||
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
||||
%browserDTD;
|
||||
<!ENTITY % aboutPrivateBrowsingDTD SYSTEM "chrome://browser/locale/aboutPrivateBrowsing.dtd">
|
||||
%aboutPrivateBrowsingDTD;
|
||||
]>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" class="private no-search-ui">
|
||||
<head>
|
||||
|
@ -12,50 +23,49 @@
|
|||
<link rel="icon" type="image/png" href="chrome://browser/skin/privatebrowsing/favicon.svg"/>
|
||||
<link rel="stylesheet" href="chrome://browser/content/aboutPrivateBrowsing.css" type="text/css" media="all"/>
|
||||
<link rel="stylesheet" href="chrome://browser/skin/privatebrowsing/aboutPrivateBrowsing.css" type="text/css" media="all"/>
|
||||
<link rel="localization" href="branding/brand.ftl"/>
|
||||
<link rel="localization" href="browser/aboutPrivateBrowsing.ftl"/>
|
||||
<script type="application/javascript" src="chrome://browser/content/aboutPrivateBrowsing.js"></script>
|
||||
<script type="application/javascript" src="chrome://browser/content/contentSearchUI.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p class="showNormal" data-l10n-id="about-private-browsing-not-private"></p>
|
||||
<body dir="&locale.dir;">
|
||||
<p class="showNormal">&aboutPrivateBrowsing.notPrivate;</p>
|
||||
<button id="startPrivateBrowsing"
|
||||
class="showNormal" data-l10n-id="privatebrowsingpage-open-private-window-label"></button>
|
||||
class="showNormal"
|
||||
accesskey="&privatebrowsingpage.openPrivateWindow.accesskey;">&privatebrowsingpage.openPrivateWindow.label;</button>
|
||||
<div class="showPrivate dontShowSearch container">
|
||||
<h1 class="title">
|
||||
<span id="title" data-l10n-id="private-browsing-title"></span>
|
||||
<span id="title">&privateBrowsing.title;</span>
|
||||
</h1>
|
||||
<section class="section-main">
|
||||
<p data-l10n-id="about-private-browsing-info-notsaved"></p>
|
||||
<p>&aboutPrivateBrowsing.info.notsaved.before;<strong>&aboutPrivateBrowsing.info.notsaved.emphasize;</strong>&aboutPrivateBrowsing.info.notsaved.after;</p>
|
||||
<ul class="list-row">
|
||||
<li data-l10n-id="about-private-browsing-info-visited"></li>
|
||||
<li data-l10n-id="about-private-browsing-info-cookies"></li>
|
||||
<li data-l10n-id="about-private-browsing-info-searches"></li>
|
||||
<li data-l10n-id="about-private-browsing-info-temporary-files"></li>
|
||||
<li>&aboutPrivateBrowsing.info.visited;</li>
|
||||
<li>&aboutPrivateBrowsing.info.cookies;</li>
|
||||
<li>&aboutPrivateBrowsing.info.searches;</li>
|
||||
<li>&aboutPrivateBrowsing.info.temporaryFiles;</li>
|
||||
</ul>
|
||||
<p data-l10n-id="about-private-browsing-info-saved"></p>
|
||||
<p>&aboutPrivateBrowsing.info.saved.before;<strong>&aboutPrivateBrowsing.info.saved.emphasize;</strong>&aboutPrivateBrowsing.info.saved.after2;</p>
|
||||
<ul class="list-row">
|
||||
<li data-l10n-id="about-private-browsing-info-bookmarks"></li>
|
||||
<li data-l10n-id="about-private-browsing-info-downloads"></li>
|
||||
<li data-l10n-id="about-private-browsing-info-clipboard"></li>
|
||||
<li>&aboutPrivateBrowsing.info.bookmarks;</li>
|
||||
<li>&aboutPrivateBrowsing.info.downloads;</li>
|
||||
<li>&aboutPrivateBrowsing.info.clipboard;</li>
|
||||
</ul>
|
||||
<p data-l10n-id="about-private-browsing-note"></p>
|
||||
<p>&aboutPrivateBrowsing.note.before;<strong>&aboutPrivateBrowsing.note.emphasize;</strong>&aboutPrivateBrowsing.note.after;</p>
|
||||
</section>
|
||||
|
||||
<h2 id="tpSubHeader" class="about-subheader">
|
||||
<span id="cbTitle" data-l10n-id="content-blocking-title"></span>
|
||||
<span id="cbTitle">&contentBlocking.title;</span>
|
||||
</h2>
|
||||
|
||||
<section id="tpSection" class="section-main">
|
||||
<p id="cbDescription" data-l10n-id="content-blocking-description"></p>
|
||||
<p id="cbDescription">&contentBlocking.description;</p>
|
||||
<p>
|
||||
<a id="startTour" class="button" data-l10n-id="tracking-protection-start-tour"></a>
|
||||
<a id="startTour" class="button">&trackingProtection.startTour1;</a>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="section-main">
|
||||
<p class="about-info" data-l10n-id="about-private-browsing-learn-more"><a id="learnMore" target="_blank" data-l10n-name="learn-more"></a></p>
|
||||
<p class="about-info">&aboutPrivateBrowsing.learnMore3.before;<a id="learnMore" target="_blank">&aboutPrivateBrowsing.learnMore3.title;</a>&aboutPrivateBrowsing.learnMore3.after;</p>
|
||||
</section>
|
||||
</div>
|
||||
<div class="showPrivate showSearch container">
|
||||
|
@ -64,17 +74,20 @@
|
|||
<div class="wordmark" />
|
||||
</div>
|
||||
<div class="search-inner-wrapper">
|
||||
<button id="search-handoff-button" class="search-handoff-button" tabindex="-1" data-l10n-id="about-private-browsing">
|
||||
<div class="fake-textbox" data-l10n-id="about-private-browsing-search-placeholder"></div>
|
||||
<button id="search-handoff-button" class="search-handoff-button" title="&aboutPrivateBrowsing.search.placeholder;" tabindex="-1">
|
||||
<div class="fake-textbox">&aboutPrivateBrowsing.search.placeholder;</div>
|
||||
<input id="fake-editable" class="fake-editable" tabindex="-1" aria-hidden="true" />
|
||||
<div class="fake-caret" />
|
||||
</button>
|
||||
<input id="dummy-input" class="dummy-input" type="search" />
|
||||
</div>
|
||||
<div class="info">
|
||||
<h1 data-l10n-id="about-private-browsing-info-title"></h1>
|
||||
<p data-l10n-id="about-private-browsing-info-description"></p>
|
||||
<a id="private-browsing-myths" data-l10n-id="about-private-browsing-info-myths"></a>
|
||||
<h1>&aboutPrivateBrowsing.info.title;</h1>
|
||||
<p>
|
||||
&aboutPrivateBrowsing.info.description;
|
||||
<br/>
|
||||
<a id="private-browsing-myths">&aboutPrivateBrowsing.info.myths;</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
about-private-browsing-learn-more = Learn more about <a data-l10n-name="learn-more">Private Browsing</a>.
|
||||
about-private-browsing-info-visited = visited pages
|
||||
privatebrowsingpage-open-private-window-label = Open a Private Window
|
||||
.accesskey = P
|
||||
about-private-browsing-info-notsaved = When you browse in a Private Window, { -brand-short-name } <strong>does not save</strong>:
|
||||
about-private-browsing-search-placeholder = Search the Web
|
||||
about-private-browsing-info-bookmarks = bookmarks
|
||||
about-private-browsing-info-title = You’re in a Private Window
|
||||
about-private-browsing-info-searches = searches
|
||||
about-private-browsing-info-downloads = downloads
|
||||
private-browsing-title = Private Browsing
|
||||
about-private-browsing-info-saved = { -brand-short-name } <strong>will save</strong> your:
|
||||
about-private-browsing-info-myths = Common myths about private browsing
|
||||
about-private-browsing-info-clipboard = copied text
|
||||
about-private-browsing-info-temporary-files = temporary files
|
||||
about-private-browsing-info-cookies = cookies
|
||||
tracking-protection-start-tour = See how it works
|
||||
about-private-browsing-note = Private Browsing <strong>doesn’t make you anonymous</strong> on the Internet. Your employer or Internet service provider can still know what page you visit.
|
||||
about-private-browsing =
|
||||
.title = Search the Web
|
||||
about-private-browsing-not-private = You are currently not in a private window.
|
||||
content-blocking-title = Content Blocking
|
||||
content-blocking-description = Some websites use trackers that can monitor your activity across the Internet. In private windows, { -brand-short-name } Content Blocking automatically blocks many trackers that can collect information about your browsing behavior.
|
||||
about-private-browsing-info-description = { -brand-short-name } clears your search and browsing history when you quit the app or close all Private Browsing tabs and windows. While this doesn’t make you anonymous to websites or your internet service provider, it makes it easier to keep what you do online private from anyone else who uses this computer.
|
|
@ -0,0 +1,43 @@
|
|||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY aboutPrivateBrowsing.notPrivate "You are currently not in a private window.">
|
||||
<!ENTITY privatebrowsingpage.openPrivateWindow.label "Open a Private Window">
|
||||
<!ENTITY privatebrowsingpage.openPrivateWindow.accesskey "P">
|
||||
|
||||
<!ENTITY privateBrowsing.title "Private Browsing">
|
||||
<!ENTITY aboutPrivateBrowsing.info.notsaved.before "When you browse in a Private Window, Firefox ">
|
||||
<!ENTITY aboutPrivateBrowsing.info.notsaved.emphasize "does not save">
|
||||
<!ENTITY aboutPrivateBrowsing.info.notsaved.after ":">
|
||||
<!ENTITY aboutPrivateBrowsing.info.visited "visited pages">
|
||||
<!ENTITY aboutPrivateBrowsing.info.searches "searches">
|
||||
<!ENTITY aboutPrivateBrowsing.info.cookies "cookies">
|
||||
<!ENTITY aboutPrivateBrowsing.info.temporaryFiles "temporary files">
|
||||
<!ENTITY aboutPrivateBrowsing.info.saved.before "Firefox ">
|
||||
<!ENTITY aboutPrivateBrowsing.info.saved.emphasize "will save">
|
||||
<!ENTITY aboutPrivateBrowsing.info.saved.after2 " your:">
|
||||
<!ENTITY aboutPrivateBrowsing.info.downloads "downloads">
|
||||
<!ENTITY aboutPrivateBrowsing.info.bookmarks "bookmarks">
|
||||
<!ENTITY aboutPrivateBrowsing.info.clipboard "copied text">
|
||||
<!ENTITY aboutPrivateBrowsing.note.before "Private Browsing ">
|
||||
<!ENTITY aboutPrivateBrowsing.note.emphasize "doesn’t make you anonymous">
|
||||
<!ENTITY aboutPrivateBrowsing.note.after " on the Internet. Your employer or Internet service provider can still know what page you visit.">
|
||||
<!ENTITY aboutPrivateBrowsing.learnMore3.before "Learn more about ">
|
||||
<!ENTITY aboutPrivateBrowsing.learnMore3.title "Private Browsing">
|
||||
<!ENTITY aboutPrivateBrowsing.learnMore3.after ".">
|
||||
|
||||
<!ENTITY trackingProtection.startTour1 "See how it works">
|
||||
|
||||
<!ENTITY contentBlocking.title "Content Blocking">
|
||||
<!ENTITY contentBlocking.description "Some websites use trackers that can monitor your activity across the Internet. In private windows, Firefox Content Blocking automatically blocks many trackers that can collect information about your browsing behavior.">
|
||||
|
||||
<!-- Strings for new Private Browsing with Search -->
|
||||
<!-- LOCALIZATION NOTE (aboutPrivateBrowsing.search.placeholder): This is the placeholder
|
||||
text for the search box. -->
|
||||
<!ENTITY aboutPrivateBrowsing.search.placeholder "Search the Web">
|
||||
<!ENTITY aboutPrivateBrowsing.info.title "You’re in a Private Window">
|
||||
<!ENTITY aboutPrivateBrowsing.info.description "&brandShortName; clears your search and browsing history when you quit the app or close all Private Browsing tabs and windows. While this doesn’t make you anonymous to websites or your internet service provider, it makes it easier to keep what you do online private from anyone else who uses this computer.">
|
||||
<!-- LOCALIZATION NOTE (aboutPrivateBrowsing.info.myths): This is a link to a SUMO article
|
||||
about private browsing myths. -->
|
||||
<!ENTITY aboutPrivateBrowsing.info.myths "Common myths about private browsing">
|
|
@ -14,7 +14,7 @@
|
|||
% locale browser @AB_CD@ %locale/browser/
|
||||
# bookmarks.html is produced by LOCALIZED_GENERATED_FILES.
|
||||
locale/browser/bookmarks.html (bookmarks.html)
|
||||
|
||||
locale/browser/aboutPrivateBrowsing.dtd (%chrome/browser/aboutPrivateBrowsing.dtd)
|
||||
locale/browser/accounts.properties (%chrome/browser/accounts.properties)
|
||||
locale/browser/browser.dtd (%chrome/browser/browser.dtd)
|
||||
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
from lib.xul import collect_messages
|
||||
from lib.dtd import get_dtds
|
||||
from lib.utils import read_file, write_file
|
||||
from lib.migration import build_migration
|
||||
from lib.fluent import build_ftl
|
||||
import json
|
||||
import argparse
|
||||
import sys
|
||||
# import re
|
||||
|
||||
|
||||
# default migration directions
|
||||
data = {
|
||||
'migration': 'python/l10n/fluent_migrations',
|
||||
'description': 'Migrate l10n strings'
|
||||
}
|
||||
|
||||
|
||||
def parse_inputs():
|
||||
sys_args = sys.argv[1:]
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('bug_id', type=str,
|
||||
help='Id number for bug tracking')
|
||||
parser.add_argument('xul', type=str,
|
||||
help='POSIX path from mozilla-central to the XML to be updated')
|
||||
parser.add_argument('ftl', type=str,
|
||||
help='Case sensitive POSIX path from mozilla-central to desired ftl file')
|
||||
parser.add_argument('mozilla_central', type=str,
|
||||
help='Case sensitive absolute POSIX path to current mozilla-central repo')
|
||||
parser.add_argument('dtd', type=str,
|
||||
help='comma delimited list of case sensitive POSIX dtd file paths')
|
||||
parser.add_argument('description', type=str,
|
||||
help='string enclosed in quotes')
|
||||
parser.add_argument('--dry-run', action='store_true',
|
||||
help='Tell if running dry run or not')
|
||||
|
||||
parsed_args = parser.parse_args(sys_args)
|
||||
|
||||
data['description'] = parsed_args.description
|
||||
data['bug_id'] = parsed_args.bug_id
|
||||
data['xul'] = parsed_args.xul
|
||||
data['ftl'] = parsed_args.ftl
|
||||
data['mozilla-central'] = parsed_args.mozilla_central
|
||||
data['dtd'] = parsed_args.dtd.split(',')
|
||||
data['dry-run'] = parsed_args.dry_run
|
||||
data['recipe'] = "bug_{}_{}.py".format(data['bug_id'],
|
||||
data['xul'].split('/')[-1].split('.')[0])
|
||||
|
||||
main()
|
||||
|
||||
|
||||
def main():
|
||||
dry_run = data['dry-run']
|
||||
dtds = get_dtds(data['dtd'], data['mozilla-central'])
|
||||
|
||||
print('======== DTDs ========')
|
||||
# with open('DTDs.json', 'w') as outfile:
|
||||
# json.dump(dtds, outfile, sort_keys=True, indent=2)
|
||||
print(json.dumps(dtds, sort_keys=True, indent=2))
|
||||
|
||||
s = read_file(data['xul'], data['mozilla-central'])
|
||||
|
||||
print('======== INPUT ========')
|
||||
print(s)
|
||||
|
||||
print('======== OUTPUT ========')
|
||||
(new_xul, messages) = collect_messages(s)
|
||||
print(new_xul)
|
||||
if not dry_run:
|
||||
write_file(data['xul'], new_xul, data['mozilla-central'])
|
||||
|
||||
print('======== L10N ========')
|
||||
|
||||
print(json.dumps(messages, sort_keys=True, indent=2))
|
||||
|
||||
migration = build_migration(messages, dtds, data)
|
||||
|
||||
print('======== MIGRATION ========')
|
||||
print(migration)
|
||||
recipe_path = "{}/{}".format(data['migration'], data['recipe'])
|
||||
if not dry_run:
|
||||
write_file(recipe_path, migration, data['mozilla-central'])
|
||||
|
||||
ftl = build_ftl(messages, dtds, data)
|
||||
|
||||
print('======== Fluent ========')
|
||||
print(ftl.encode("utf-8"))
|
||||
if not dry_run:
|
||||
write_file(data['ftl'], ftl.encode("utf-8"), data['mozilla-central'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parse_inputs()
|
|
@ -1,2 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
# from .xul import collect_messages
|
|
@ -1,27 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
from io import StringIO
|
||||
from lxml import etree
|
||||
from .utils import read_file
|
||||
|
||||
|
||||
def get_dtds(sources, base_path):
|
||||
entries = {}
|
||||
for source in sources:
|
||||
dtd = get_dtd(source, base_path)
|
||||
for entry in dtd:
|
||||
entries[entry] = {
|
||||
"value": dtd[entry],
|
||||
"file": source
|
||||
}
|
||||
return entries
|
||||
|
||||
|
||||
def get_dtd(dtd_source, base_path):
|
||||
entries = {}
|
||||
|
||||
source = read_file(dtd_source, base_path)
|
||||
|
||||
dtd = etree.DTD(StringIO(source.decode("utf-8")))
|
||||
for entity in dtd.entities():
|
||||
entries[entity.name] = entity.content
|
||||
return entries
|
|
@ -1,30 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
from syntax import ast
|
||||
from syntax.serializer import FluentSerializer
|
||||
|
||||
|
||||
def get_value_from_dtd(name, dtd):
|
||||
return dtd[name[1:-1]]['value']
|
||||
|
||||
|
||||
def build_ftl(messages, dtd, data):
|
||||
res = ast.Resource()
|
||||
|
||||
for id_str in messages:
|
||||
msg = messages[id_str]
|
||||
l10n_id = ast.Identifier(id_str)
|
||||
val = None
|
||||
attrs = []
|
||||
if msg['value']:
|
||||
dtd_val = get_value_from_dtd(msg['value'], dtd)
|
||||
val = ast.Pattern([ast.TextElement(dtd_val)])
|
||||
for attr_name in msg['attrs']:
|
||||
dtd_val = get_value_from_dtd(msg['attrs'][attr_name], dtd)
|
||||
attr_val = ast.Pattern([ast.TextElement(dtd_val)])
|
||||
attrs.append(ast.Attribute(ast.Identifier(attr_name), attr_val))
|
||||
|
||||
m = ast.Message(l10n_id, val, attrs)
|
||||
res.body.append(m)
|
||||
|
||||
serializer = FluentSerializer()
|
||||
return serializer.serialize(res)
|
|
@ -1,67 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
|
||||
def to_chrome_path(path):
|
||||
return path.replace('/locales/en-US', '')
|
||||
return path
|
||||
|
||||
|
||||
def get_dtd_path(name, dtds):
|
||||
return dtds[name[1:-1]]['file']
|
||||
|
||||
|
||||
def get_entity_name(s):
|
||||
return s[1:-1]
|
||||
|
||||
|
||||
def ind(n=0):
|
||||
return ' ' * 4 * n
|
||||
|
||||
|
||||
def add_copy(dtd, entity_id, indent, prefix=""):
|
||||
result = '{0}{1}COPY(\n'.format(ind(indent), prefix)
|
||||
result += '{0}\'{1}\',\n'.format(ind(indent + 1), to_chrome_path(dtd))
|
||||
result += '{0}\'{1}\',\n'.format(
|
||||
ind(indent + 1), get_entity_name(entity_id))
|
||||
result += '{0}),\n'.format(ind(indent))
|
||||
return result
|
||||
|
||||
|
||||
def build_migration(messages, dtds, data):
|
||||
res = 'import fluent.syntax as FTL\n'
|
||||
|
||||
features = ['COPY']
|
||||
res += 'from fluent.migrate import {0}\n'.format(','.join(features))
|
||||
desc = 'Bug {0} - {1}, part {{index}}'.format(
|
||||
data['bug_id'], data['description'])
|
||||
res += '\n\ndef migrate(ctx):\n """{0}"""\n\n'.format(desc)
|
||||
|
||||
for dtd_path in data['dtd']:
|
||||
res += "{0}ctx.maybe_add_localization('{1}')\n".format(
|
||||
ind(1), to_chrome_path(dtd_path))
|
||||
|
||||
res += '\n'
|
||||
res += ind(1) + 'ctx.add_transforms(\n'
|
||||
res += ind(2) + '{0},\n'.format(to_chrome_path(data['ftl']))
|
||||
res += ind(2) + '{0},\n'.format(to_chrome_path(data['ftl']))
|
||||
res += ind(2) + '[\n'
|
||||
for l10n_id in messages:
|
||||
msg = messages[l10n_id]
|
||||
res += ind(3) + 'FTL.Message(\n'
|
||||
res += ind(4) + 'id=FTL.Identifier(\'{0}\'),\n'.format(l10n_id)
|
||||
if msg['value']:
|
||||
res += add_copy(get_dtd_path(msg['value'], dtds), msg['value'], 4, 'value=')
|
||||
if msg['attrs']:
|
||||
res += ind(4) + 'attributes=[\n'
|
||||
for name in msg['attrs']:
|
||||
attr = msg['attrs'][name]
|
||||
res += ind(5) + 'FTL.Attribute(\n'
|
||||
res += ind(6) + 'FTL.Identifier(\'{0}\'),\n'.format(name)
|
||||
res += add_copy(get_dtd_path(attr, dtds), attr, 6)
|
||||
res += ind(5) + '),\n'
|
||||
res += ind(4) + '],\n'
|
||||
res += ind(3) + '),\n'
|
||||
res += ind(2) + ']\n'
|
||||
res += ind(1) + ')'
|
||||
|
||||
return res
|
|
@ -1,18 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
import os
|
||||
|
||||
|
||||
def read_file(path, base_path=None):
|
||||
if base_path is not None:
|
||||
path = os.path.join(base_path, path)
|
||||
path = path.replace('\\', '/')
|
||||
with open(path) as fptr:
|
||||
return fptr.read()
|
||||
|
||||
|
||||
def write_file(path, text, base_path=None):
|
||||
if base_path is not None:
|
||||
path = os.path.join(base_path, path)
|
||||
path = path.replace('\\', '/')
|
||||
with open(path, "w") as text_file:
|
||||
text_file.write(text)
|
|
@ -1,94 +0,0 @@
|
|||
from __future__ import absolute_import
|
||||
import re
|
||||
|
||||
tag_re = r'<([a-z]+[^>/]*)(/?>)([^<]*)(?:</[a-z]+>)?'
|
||||
attr_re = r'\s+([a-z]+)="([\&\;\.a-zA-Z0-9]+)"'
|
||||
|
||||
messages = {}
|
||||
|
||||
|
||||
def is_entity(s):
|
||||
return s.startswith('&') and s.endswith(';')
|
||||
|
||||
|
||||
def convert_camel_case(name):
|
||||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', name)
|
||||
return re.sub('([a-z0-9])([A-Z])', r'\1-\2', s1).lower()
|
||||
|
||||
|
||||
def construct_l10n_id(val, attrs):
|
||||
id = None
|
||||
if val:
|
||||
id = val[1:-1]
|
||||
else:
|
||||
core = None
|
||||
for k in attrs:
|
||||
v = attrs[k][1:-1].split('.')
|
||||
if not core:
|
||||
core = v[0]
|
||||
if core:
|
||||
id = core
|
||||
id = id.replace('.', '-')
|
||||
id = convert_camel_case(id)
|
||||
return id
|
||||
|
||||
|
||||
vector = 0
|
||||
is_l10n = False
|
||||
|
||||
|
||||
def tagrepl(m):
|
||||
global vector
|
||||
global is_l10n
|
||||
vector = 0
|
||||
|
||||
is_l10n = False
|
||||
l10n_val = None
|
||||
l10n_attrs = {}
|
||||
if is_entity(m.group(3)):
|
||||
is_l10n = True
|
||||
l10n_val = m.group(3)
|
||||
|
||||
def attrrepl(m2):
|
||||
global vector
|
||||
global is_l10n
|
||||
attr_l10n = False
|
||||
if is_entity(m2.group(2)):
|
||||
attr_l10n = True
|
||||
l10n_attrs[m2.group(1)] = m2.group(2)
|
||||
|
||||
if attr_l10n:
|
||||
is_l10n = True
|
||||
vector = vector + len(m2.group(0))
|
||||
return ""
|
||||
return m2.group(0)
|
||||
|
||||
tag = re.sub(attr_re, attrrepl, m.group(0))
|
||||
if is_l10n:
|
||||
l10n_id = construct_l10n_id(l10n_val, l10n_attrs)
|
||||
messages[l10n_id] = {
|
||||
"value": l10n_val,
|
||||
"attrs": l10n_attrs
|
||||
}
|
||||
tag = \
|
||||
tag[0:len(m.group(1)) + 1 - vector] + \
|
||||
' data-l10n-id="' + \
|
||||
l10n_id + \
|
||||
'"' + \
|
||||
m.group(2) + \
|
||||
(m.group(3) if not l10n_val else "") + \
|
||||
tag[len(m.group(1)) + 1 + len(m.group(2)) +
|
||||
len(m.group(3)) - vector:]
|
||||
return tag
|
||||
|
||||
|
||||
def collect_messages(xul_source):
|
||||
global messages
|
||||
messages = {}
|
||||
|
||||
new_source = re.sub(tag_re, tagrepl, xul_source)
|
||||
return (new_source, messages)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
|
@ -1,175 +0,0 @@
|
|||
# coding=utf8
|
||||
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
from __future__ import absolute_import
|
||||
import fluent.syntax.ast as FTL
|
||||
from fluent.migrate.helpers import transforms_from
|
||||
from fluent.migrate.helpers import MESSAGE_REFERENCE, TERM_REFERENCE
|
||||
from fluent.migrate import COPY, CONCAT, REPLACE
|
||||
|
||||
def migrate(ctx):
|
||||
"""Bug 1517528 - Migrate aboutPrivateBrowsing from DTD to Fluent, part {index}"""
|
||||
|
||||
ctx.add_transforms(
|
||||
'browser/browser/aboutPrivateBrowsing.ftl',
|
||||
'browser/browser/aboutPrivateBrowsing.ftl',
|
||||
transforms_from(
|
||||
"""
|
||||
about-private-browsing-info-visited = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.visited") }
|
||||
about-private-browsing-search-placeholder = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.search.placeholder") }
|
||||
about-private-browsing-info-bookmarks = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.bookmarks") }
|
||||
about-private-browsing-info-title = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.title") }
|
||||
about-private-browsing-info-downloads = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.downloads") }
|
||||
about-private-browsing-info-searches = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.searches") }
|
||||
private-browsing-title = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "privateBrowsing.title") }
|
||||
about-private-browsing-not-private = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.notPrivate") }
|
||||
content-blocking-title = { COPY("browser/chrome/browser/browser.dtd", "contentBlocking.title") }
|
||||
about-private-browsing-info-myths = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.myths") }
|
||||
about-private-browsing-info-clipboard = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.clipboard") }
|
||||
about-private-browsing-info-temporary-files = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.temporaryFiles") }
|
||||
about-private-browsing-info-cookies = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "aboutPrivateBrowsing.info.cookies") }
|
||||
tracking-protection-start-tour = { COPY("browser/chrome/browser/aboutPrivateBrowsing.dtd", "trackingProtection.startTour1") }
|
||||
"""
|
||||
)
|
||||
),
|
||||
ctx.add_transforms(
|
||||
'browser/browser/aboutPrivateBrowsing.ftl',
|
||||
'browser/browser/aboutPrivateBrowsing.ftl',
|
||||
[
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing-learn-more'),
|
||||
value=CONCAT(
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.learnMore3.before'
|
||||
),
|
||||
FTL.TextElement('<a data-l10n-name="learn-more">'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.learnMore3.title'
|
||||
),
|
||||
FTL.TextElement('</a>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.learnMore3.after'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('privatebrowsingpage-open-private-window-label'),
|
||||
value=COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'privatebrowsingpage.openPrivateWindow.label',
|
||||
),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
FTL.Identifier('accesskey'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'privatebrowsingpage.openPrivateWindow.accesskey',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing-info-notsaved'),
|
||||
value=CONCAT(
|
||||
REPLACE(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.notsaved.before',
|
||||
{
|
||||
"Firefox": TERM_REFERENCE("brand-short-name")
|
||||
}
|
||||
),
|
||||
FTL.TextElement('<strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.notsaved.emphasize'
|
||||
),
|
||||
FTL.TextElement('</strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.notsaved.after'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing-info-saved'),
|
||||
value=CONCAT(
|
||||
REPLACE(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.saved.before',
|
||||
{
|
||||
"Firefox": TERM_REFERENCE("brand-short-name")
|
||||
}
|
||||
),
|
||||
FTL.TextElement('<strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.saved.emphasize'
|
||||
),
|
||||
FTL.TextElement('</strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.saved.after2'
|
||||
)
|
||||
)
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing-note'),
|
||||
value=CONCAT(
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.note.before'
|
||||
),
|
||||
FTL.TextElement('<strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.note.emphasize'
|
||||
),
|
||||
FTL.TextElement('</strong>'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.note.after'
|
||||
)
|
||||
)
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing'),
|
||||
attributes=[
|
||||
FTL.Attribute(
|
||||
FTL.Identifier('title'),
|
||||
COPY(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.search.placeholder',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('about-private-browsing-info-description'),
|
||||
value=REPLACE(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'aboutPrivateBrowsing.info.description',
|
||||
{
|
||||
"&brandShortName;": TERM_REFERENCE("brand-short-name")
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
FTL.Message(
|
||||
id=FTL.Identifier('content-blocking-description'),
|
||||
value=REPLACE(
|
||||
'browser/chrome/browser/aboutPrivateBrowsing.dtd',
|
||||
'contentBlocking.description',
|
||||
{
|
||||
"Firefox": TERM_REFERENCE("brand-short-name")
|
||||
}
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
|
@ -37,11 +37,10 @@ class TestAboutPrivateBrowsing(PuppeteerMixin, MarionetteTestCase):
|
|||
with self.marionette.using_context('content'):
|
||||
self.marionette.navigate('about:privatebrowsing')
|
||||
|
||||
# Disabled awaiting support for Fluent strings in firefox-ui tests (bug 1534310)
|
||||
# status_node = self.marionette.find_element(By.CSS_SELECTOR, 'p.showNormal')
|
||||
# self.assertEqual(status_node.text,
|
||||
# self.browser.localize_entity('aboutPrivateBrowsing.notPrivate'),
|
||||
# 'Status text indicates we are not in private browsing mode')
|
||||
status_node = self.marionette.find_element(By.CSS_SELECTOR, 'p.showNormal')
|
||||
self.assertEqual(status_node.text,
|
||||
self.browser.localize_entity('aboutPrivateBrowsing.notPrivate'),
|
||||
'Status text indicates we are not in private browsing mode')
|
||||
|
||||
def window_opener(win):
|
||||
with win.marionette.using_context('content'):
|
||||
|
@ -96,11 +95,10 @@ class TestAboutPrivateBrowsingWithSearch(PuppeteerMixin, MarionetteTestCase):
|
|||
with self.marionette.using_context('content'):
|
||||
self.marionette.navigate('about:privatebrowsing')
|
||||
|
||||
# Disabled awaiting support for Fluent strings in firefox-ui tests (bug 1534310)
|
||||
# status_node = self.marionette.find_element(By.CSS_SELECTOR, 'p.showNormal')
|
||||
# self.assertEqual(status_node.text,
|
||||
# self.browser.localize_entity('aboutPrivateBrowsing.notPrivate'),
|
||||
# 'Status text indicates we are not in private browsing mode')
|
||||
status_node = self.marionette.find_element(By.CSS_SELECTOR, 'p.showNormal')
|
||||
self.assertEqual(status_node.text,
|
||||
self.browser.localize_entity('aboutPrivateBrowsing.notPrivate'),
|
||||
'Status text indicates we are not in private browsing mode')
|
||||
|
||||
def window_opener(win):
|
||||
with win.marionette.using_context('content'):
|
||||
|
|
|
@ -28,6 +28,7 @@ class BrowserWindow(BaseWindow):
|
|||
|
||||
dtds = [
|
||||
'chrome://branding/locale/brand.dtd',
|
||||
'chrome://browser/locale/aboutPrivateBrowsing.dtd',
|
||||
'chrome://browser/locale/browser.dtd',
|
||||
'chrome://browser/locale/netError.dtd',
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче