diff --git a/README.md b/README.md index 1d987db..d9de88c 100644 --- a/README.md +++ b/README.md @@ -52,17 +52,17 @@ $ ./mediawiki.py --dir mydir/ --lang 'ru,es' ## Other notes -Overview +### Overview Translate an input mediawiki file of Spanish and generate an output mediawiki file of English. orig_input.txt -> script -> orgi_output.txt -Inputs +### Inputs - input file - Language of output file (default: Spanish) - Language of output files can be a list of languages eg 'ru,es' would be for Russian and Spanish. - input directory - so need to get a list of all files in that directory and then parse each one of them. -Outputs +### Outputs - output file with the name of the file "myfile-es.txt' if the input is "myfile.txt" - status - success (zero) or @@ -73,37 +73,48 @@ Outputs ### Control Flow -1. Open and read input file -2. Parse input file into a data structure -3. Send requests to Cloud Translation to perform the language conversion -4. Create and write to output file +1. Open and read input file. +1. Parse input file into a data structure. +1. Process each line one at a time. +1. For each line replace special text sequences with a symbol as we may want to translate these separately. +1. Send requests to Cloud Translation to perform the language conversion. +1. Create and write to output file. -Error conditions +#### Error conditions - Cannot find input file - Empty input file - Format of input file not valid according to mediawiki - Unable to send requests to Cloud Translation - Unable to create output file -Data structure(s) +#### Data structure(s) -List of objects -- Object +##### List of objects +- Object - for each line in the input file. + - Original Line - Original line of text from the input file, in English, say. + - Translated Line - The final translated line of text into the requested output language - Line number - Line number of the input file. - - Sequence - The unique sequence to indicate the special sequence that we don't want to translate. - - Original - The original text (in English, say). + - Sequence Line - After special sequences of interest within the original line have been replaced with a special squences so that we don't want to translate these. + - Sequences - List of the unique sequences in the current line, we may or may not want to translate individually. + - Empty Line - Boolean true or false so that we don't ask Google to translate an empty string. + +- Object - for each unique sequence for a given line. + - sequence - This is a special sequence that looks like 123-456, say. + - original - This is the original string before any translations. + - translate - Boolean true or false if we would like to translate the sting or leave it in the original language. + ### Detailed Design #### Control Flow -- Start with the parsing of the input arguments to verify them. -- Parse over the input file -- Look at one line at a time -- Look for specific patterns of interest in the input file and if they are special then remove them from the line and replace them with a unique tag. -- Then send the remaining line to Google Cloud Translate API -- Each of the special unique tags replace them with the original content -- OR some of the special unique tags we need to still translate them but just a bit of their content -- write the line to the output file +1. Start with the parsing of the input arguments to verify them. +1. Parse over the input file +1. Look at one line at a time +1. Look for specific patterns of interest in the input file and if they are special then remove them from the line and replace them with a unique tag. +1. Then send the remaining line to Google Cloud Translate API +1. Each of the special unique tags replace them with the original content +1. OR some of the special unique tags we need to still translate them but just a bit of their content +1. write the line to the output file #### Data Flow - Need to add more details here. diff --git a/WikiParser.py b/WikiParser.py index c131212..40c656a 100644 --- a/WikiParser.py +++ b/WikiParser.py @@ -59,6 +59,7 @@ class WikiParser(object): + # TODO: It would be better to have this for each line we process in the file, not as a class variable. listOfUsedNumbers = [] # Constructor. @@ -79,7 +80,9 @@ def __init__(self, inputFilename, outputLanguage=DEFAULT_OUTPUT_LANGUAGE, inputL raise ValueError("Error: Input file (" + inputFilename + ") is empty.") if outputLanguage == inputLanguage: - raise ValueError("Error: Input Language (" + inputLanguage + ") same as output Language (" + outputLanguage + ")") + errStr = "Error: Input Language (" + inputLanguage + ")" + errStr += " same as output Language (" + outputLanguage + ")" + raise ValueError(errStr) # Extract the raw input filename and its extension. rawInputFilename, inputFilenameExtension = os.path.splitext(inputFilename) @@ -107,8 +110,17 @@ def __init__(self, inputFilename, outputLanguage=DEFAULT_OUTPUT_LANGUAGE, inputL self.mTranslateClient = translate.TranslationServiceClient() self.mParent = self.mTranslateClient.location_path(project_id, location) - # Parse the Mediawiki file and load into our data structure. - self.parseMediaWikiFile() + + # + # Perform the work to process the data. + # + def readProcessTranslateWrite(self): + + # Read, process, translate and write the media wiki file. + self.readMediaWikiFile() + self.processMediaWikiFile() + self.translateMediaWikiFile() + self.writeMediaWikiFile() # @@ -135,9 +147,9 @@ def giveMeUniqueRandomNumber(self): # - # Parse the Mediawiki input file and store into a data structure. + # Load the media wiki file into an internal data structure. # - def parseMediaWikiFile(self): + def readMediaWikiFile(self): # Keep track of the line counter. # First line starts at number one. @@ -149,181 +161,258 @@ def parseMediaWikiFile(self): # Gobble the end of line character. currentLine = currentLine.rstrip() - # Verify we are not processing an empty line. + # Verify if we are processing an empty line. if not currentLine: - # Write a new line to the output file. - self.mOutputFileFh.write("\n") - - # Keep track of the current line we are parsing. - lineCounter = lineCounter + 1 - - # Don't process any further as this line is empty. - continue - - - # Look for any special strings in the line and then replace it with a special number - # Then we can replace the special number later. - patternsToReplaceOrTranslate = [{"pattern":"(\{for[\s\w\-\_\.\,\'\’\=]+\})", - "translate": False}, - {"pattern":"(\{\/for\})", - "translate": False}, - {"pattern":"\{(button[\s\w\-\_\.\,\'\’\=]+)\}", - "translate": False}, - {"pattern":"\{(menu[\s\w\-\_\.\,\'\’\=]+)\}", - "translate": False}, - {"pattern":"(\{note\})", - "translate": False}, - {"pattern":"(\{\/note\})", - "translate": False}, - {"pattern":"(\{warning\})", - "translate": False}, - {"pattern":"(\{\/warning\})", - "translate": False}, - {"pattern":"\_\_TOC\_\_", - "translate": False}, - {"pattern":"\_\_FORCETOC\_\_", - "translate": False}, - {"pattern":"\_\_NOTOC\_\_", - "translate": False}, - {"pattern":"\[\[Template\:[\w+\s]+\]\]", - "translate": False}, - {"pattern":"\;*\[\[Image\:[\w\-\s\=\/\|]+\]\]", - "translate": False}, - {"pattern":"\[\[Video\:[\w\s\:\/\.\_]+\]\]", - "translate": False}, - {"pattern":"\[\[([\s\w\-\_\#\,\"]+)\|[\w\s]+\]\]", - "translate": False}, - {"pattern":"\[\[T\:[\w\s\-\|\=\_]+\]\]", - "translate": False}, - {"pattern":"\[\[[\s\w\-\_\#\,\"\/\.\?]+\]\]", - "translate": False}, - {"pattern":"\-\-\-\-", - "translate": False}, - {"pattern":"\<\!\-\-", - "translate": False}, - {"pattern":"\-\-\>", - "translate": False}, - {"pattern":"\", - "translate": False}, - - ############################# - {"pattern":"\(([\s\w]+)\)", - "translate": True}, - {"pattern":"\=([\s\w]+)\=", - "translate": True}, - {"pattern":"\[\[[\s\d]+\|([\w\s]+)\]\]", - "translate": True}, - {"pattern":"(\'\'\'[\s\w\-\_\#\,\"\.\?\:\>\<]+\'\'\')", - "translate": True}, - {"pattern":"(\'\'[\s\w\-\_\#\,\"\.\?\:\>\<]+\'\')", - "translate": True}, - ################################# - {"pattern":"(\"[\s\w\-\_\#\,\.\?\:\>\<]+\")", - "translate": True}, - ] - - - # Patterns we want to replace with a special unique tag then we can put it back after - # into the final translation. - for replacePattern in patternsToReplaceOrTranslate: - - currentPattern = re.compile(replacePattern["pattern"], re.IGNORECASE) - currentMatch = re.findall(currentPattern, currentLine) - - if currentMatch: - # Deal with multiple matches on the same line. - for elementMatch in currentMatch: - - specialSequence = str(self.giveMeUniqueRandomNumber()) - currentLine = currentLine.replace(elementMatch, " " + specialSequence + " ") - - # Store this match so we can refer to it later. - self.mMedia.append({"line": lineCounter, - "sequence": specialSequence, - "original": elementMatch, - "translate": replacePattern["translate"]}) - - # Translates some text into Spanish 'espanol = es' as default. - response = self.mTranslateClient.translate_text(parent=self.mParent, - contents=[currentLine], - mime_type='text/html', - source_language_code=self.mInputLanguage, - target_language_code=self.mOutputLanguage) - currentLineTranslated = "" - for currentTanslation in response.translations: - currentLineTranslated = currentTanslation.translated_text - break - - # Now I need to replace each of the special sequences. - # Look through all the special sequences we have discovered so far. - for currentMedia in self.mMedia: - # Is this the line we are currently looking at? - if currentMedia['line'] == lineCounter: - # Get it back to its original form. - if currentMedia['translate']: - - response = self.mTranslateClient.translate_text(parent=self.mParent, - contents=[currentMedia['original']], - mime_type='text/plain', - source_language_code=self.mInputLanguage, - target_language_code=self.mOutputLanguage) - - specialTranslated = "" - - for currentTanslation in response.translations: - specialTranslated = currentTanslation.translated_text - break - - currentLineTranslated = currentLineTranslated.replace(str(currentMedia['sequence']), - specialTranslated.rstrip()) - else: - currentLineTranslated = currentLineTranslated.replace(str(currentMedia['sequence']), - currentMedia['original'].decode('utf8')) - - # Final clean up for "= something =" change to "=something=" - # Clean up the spaces that are inbetween links and discrptions. - patternsToCleanup = {"^\#\s+": "#", - "^\#\s*\*\s*": "#*", - "^\*\s+": "*", - "^\=\s+": "=", - "^\s*": "", - "\s+\=$": "=", - "\s*\|\s*": "|", - } - - # Clean up some patterns. - for cleanupPattern, cleanupSub in patternsToCleanup.iteritems(): - - currentPattern = re.compile(cleanupPattern, re.IGNORECASE) - currentMatch = re.findall(currentPattern, currentLineTranslated) - - if currentMatch: - for elementMatch in currentMatch: - currentLineTranslated = re.sub(re.escape(elementMatch), cleanupSub, currentLineTranslated) + self.mMedia.append({"originalLine": "", + "translatedLine": "", + "lineNumber": lineCounter, + "sequenceLine": "", + "sequences": [], + "emptyLine": True + }) + else: + self.mMedia.append({"originalLine": currentLine, + "translatedLine": "", + "lineNumber": lineCounter, + "sequenceLine": "", + "sequences": [], + "emptyLine": False + }) + + lineCounter += 1 - # Write the current translated line to the output file. - self.mOutputFileFh.write(currentLineTranslated.encode('utf8') + "\n") + # + # Using divide and conquer approach, lets process the media wiki file to + # smaller parts that we can translate a bit at a time. + # + def processMediaWikiFile(self): + + # Process one line at a time. + for currentMedia in self.mMedia: + if not currentMedia["emptyLine"]: + self.processMediaWikiLine(currentMedia) - # Keep track of the current line we are parsing. - lineCounter = lineCounter + 1 - # Keep track of the number of lines parsed in the input file. - self.mLinecount = lineCounter + # + # Perform the Goole Cloud translation of the string sequences + # that we are interested in and then recconstruct the translated + # lines with some formatting clean-up. + # + def translateMediaWikiFile(self): + + # Translate one line at a time. + for currentMedia in self.mMedia: + if not currentMedia["emptyLine"]: + self.translateMediaWikiLine(currentMedia) + self.cleanupMediaWikiLine(currentMedia) + + + # + # Write out the media wiki file. + # + def writeMediaWikiFile(self): + + # Translate one line at a time. + for currentMedia in self.mMedia: + # Write the current translated line to the output file. + self.mOutputFileFh.write(currentMedia["translatedLine"].encode('utf8') + "\n") self.mOutputFileFh.close() + + # + # Process one line at a time. + # + def processMediaWikiLine(self, mediaLine): + + mediaLine["sequenceLine"] = mediaLine["originalLine"] + + # Look for any special strings in the line and then replace it with a special number + # Then we can replace the special number later. + patternsToReplaceOrTranslate = [{"pattern":"(\{for[\s\w\-\_\.\,\'\’\=]+\})", + "translate": False}, + {"pattern":"(\{\/for\})", + "translate": False}, + {"pattern":"\{(button[\s\w\-\_\.\,\'\’\=]+)\}", + "translate": False}, + {"pattern":"(\{filepath[\s\w\-\_\.\,\'\’\=]+\})", + "translate": False}, + {"pattern":"(\{key[\s\w\-\_\.\,\'\’\=]+\})", + "translate": False}, + {"pattern":"\{(menu[\s\w\-\_\.\,\'\’\=]+)\}", + "translate": False}, + {"pattern":"(\{note\})", + "translate": False}, + {"pattern":"(\{\/note\})", + "translate": False}, + {"pattern":"(\{warning\})", + "translate": False}, + {"pattern":"(\{\/warning\})", + "translate": False}, + {"pattern":"\_\_TOC\_\_", + "translate": False}, + {"pattern":"\_\_FORCETOC\_\_", + "translate": False}, + {"pattern":"\_\_NOTOC\_\_", + "translate": False}, + {"pattern":"\[\[Template\:[\w+\s]+\]\]", + "translate": False}, + {"pattern":"\;*\[\[Image\:[\w\-\s\=\/\|]+\]\]", + "translate": False}, + {"pattern":"\[\[Video\:[\w\s\:\/\.\_]+\]\]", + "translate": False}, + {"pattern":"\[\[([\s\w\-\_\#\,\"]+)\|[\w\s]+\]\]", + "translate": False}, + {"pattern":"\[\[T\:[\w\s\-\|\=\_]+\]\]", + "translate": False}, + {"pattern":"\[\[[\:\s\w\-\_\#\,\"\/\.\?]+\\=]\]", + "translate": False}, + {"pattern":"\[[\:\s\w\-\_\#\,\"\/\.\?\=]+\]", + "translate": False}, + {"pattern":"\-\-\-\-", + "translate": False}, + {"pattern":"\<\!\-\-", + "translate": False}, + {"pattern":"\-\-\>", + "translate": False}, + {"pattern":"\", + "translate": False}, + ############################# + {"pattern":"\(([\s\w]+)\)", + "translate": True}, + {"pattern":"\=([\s\w]+)\=", + "translate": True}, + {"pattern":"\[\[[\s\d]+\|([\w\s]+)\]\]", + "translate": True}, + {"pattern":"(\'\'\'[\s\w\-\_\#\,\"\.\?\:\>\<]+\'\'\')", + "translate": True}, + {"pattern":"(\'\'[\s\w\-\_\#\,\"\.\?\:\>\<\’]+\'\')", + "translate": True}, + ################################# + {"pattern":"(\"http[\s\w\-\_\#\,\.\?\:\>\<\/]+\")", + "translate": False}, + {"pattern":"(\"[\s\w\-\_\#\,\.\?\:\>\<\/]+\")", + "translate": True}, + ] + + # Patterns we want to replace with a special unique tag then we can put it back after + # into the final translation. + for replacePattern in patternsToReplaceOrTranslate: + + currentPattern = re.compile(replacePattern["pattern"], re.IGNORECASE) + currentMatch = re.findall(currentPattern, mediaLine["sequenceLine"]) + + if currentMatch: + # Deal with multiple matches on the same line. + for elementMatch in currentMatch: + + specialSequence = str(self.giveMeUniqueRandomNumber()) + mediaLine["sequenceLine"] = mediaLine["sequenceLine"].replace(elementMatch, " " + specialSequence + " ") + + # Store this match so we can refer to it later. + mediaLine["sequences"].append({"sequence": specialSequence, + "original": elementMatch, + "translate": replacePattern["translate"]}) + + + # + # Perform the Google Translation on the requested line of information. + # + def translateMediaWikiLine(self, mediaLine): + + # Translate the sequence line. + # Then we shall translate each of the sequences. + # Then finally we need to replace the sequences. + + # Google Cloud Translate. + # For the whole line we need to use html otherwise get + # some unprintable characters in the translated string. + response = self.mTranslateClient.translate_text(parent=self.mParent, + contents=[mediaLine["sequenceLine"]], + mime_type='text/html', # Mime types: text/plain, text/html. + source_language_code=self.mInputLanguage, + target_language_code=self.mOutputLanguage) + + for currentTanslation in response.translations: + mediaLine["translatedLine"] = currentTanslation.translated_text + break + + # Reverse the list, so roll back the sequence replacements. + for currentSequence in reversed(mediaLine["sequences"]): + if currentSequence["translate"]: + # Translate first, then make the substitution. + # We can have quotes in the special substitutions so need to + response = self.mTranslateClient.translate_text(parent=self.mParent, + contents=[currentSequence['original']], + mime_type='text/plain', # Mime types: text/plain, text/html. + source_language_code=self.mInputLanguage, + target_language_code=self.mOutputLanguage) + sequenceTranslated = "" + + for currentTanslation in response.translations: + sequenceTranslated = currentTanslation.translated_text + break + + mediaLine["translatedLine"] = mediaLine["translatedLine"].replace(str(currentSequence["sequence"]), + sequenceTranslated.rstrip()) + + else: + # No translation required just a substitution. + mediaLine["translatedLine"] = mediaLine["translatedLine"].replace(str(currentSequence["sequence"]), + currentSequence["original"].decode('utf8')) + + + # + # When sending text to Google Translation API we need to perform some clean-up on the + # string that is returned due to extra white spaces that get added. + # + def cleanupMediaWikiLine(self, mediaLine): + + # Final clean up for "= something =" change to "=something=" + # Clean up the spaces that are in between links and discrptions. + patternsToCleanup = {"^\#\s+": "#", + "^\#\s*\*\s*": "#*", + "^\*\s+": "*", + "^\=\s+": "=", + "^\s*": "", + "\s+\=$": "=", + "\s*\|\s*": "|", + "\'\'\s*\'": "'''", + "\'\s*\'\'": "'''", + """: "'", + } + + # Clean up some patterns. + for cleanupPattern, cleanupSub in patternsToCleanup.iteritems(): + + currentPattern = re.compile(cleanupPattern, re.IGNORECASE) + currentMatch = re.findall(currentPattern, mediaLine["translatedLine"]) + + if currentMatch: + for elementMatch in currentMatch: + mediaLine["translatedLine"] = re.sub(re.escape(elementMatch), + cleanupSub, + mediaLine["translatedLine"]) + + # # Helpful to better understand what is inside the data scructure. # def printWikiParser(self, depth=0): print "###" - print "# Filename:\t" + str(self.mInputFilename) + print "# Filename:\t" + str(self.getInputFilename()) for currentElement in self.mMedia: - print "\tline:\t\t" + str(currentElement["line"]) - print "\tsequence:\t\t" + str(currentElement["sequence"]) - print "\toriginal:\t\t" + str(currentElement["original"]) + if not currentElement["emptyLine"]: + print " Original:" + print " " + str(currentElement["originalLine"]) + print " " + str(currentElement["sequenceLine"]) + for currentSequence in currentElement["sequences"]: + print currentSequence["sequence"] + print currentSequence["original"] + print currentSequence["translate"] + print "---" # Gettas. diff --git a/mediawiki.py b/mediawiki.py index 3f16508..9b1f0fa 100755 --- a/mediawiki.py +++ b/mediawiki.py @@ -205,8 +205,10 @@ def main(): mediawikiParser = WikiParser.WikiParser(inputFilename = inputArgs[''], outputLanguage = currentLang) + mediawikiParser.readProcessTranslateWrite() else: mediawikiParser = WikiParser.WikiParser(inputFilename = inputArgs['']) + mediawikiParser.readProcessTranslateWrite() except ValueError as exception: # what was the details of the error. @@ -249,8 +251,10 @@ def main(): mediawikiParser = WikiParser.WikiParser(inputFilename = inputDir + currentFile, outputLanguage = currentLang) + mediawikiParser.readProcessTranslateWrite() else: mediawikiParser = WikiParser.WikiParser(inputFilename = inputDir + currentFile) + mediawikiParser.readProcessTranslateWrite() # DEBUG: Report the data structure of special sequences. # mediawikiParser.printWikiParser() diff --git a/samples/Enable and disable cookies that websites use to track your preferences.txt b/samples/Enable and disable cookies that websites use to track your preferences.txt new file mode 100644 index 0000000..69518c1 --- /dev/null +++ b/samples/Enable and disable cookies that websites use to track your preferences.txt @@ -0,0 +1,57 @@ +Enable and disable cookies that websites use to track your preferences + +[[Cookies - Information that websites store on your computer|Cookies]] are stored on your computer by websites you visit and contain information such as site preferences or your login status. This article describes how to enable and disable cookies in Firefox. + +__TOC__ + += How do I view or change my cookie settings? = +{note}'''Note: Cookies are enabled by default in Firefox.'''{/note} + +{for not fx63} +# [[T:optionspreferences]] +# Select the {menu Privacy & Security} panel and go to the '''Cookies and Site Data''' section. +# Select '''Accept cookies and site data from websites (recommended)''' to enable cookies. To disable cookies, select '''Block cookies and site data (may cause websites to break)'''. +#;{for =fx60}[[Image:Fx60Settings-CookiesAndSiteData]]{/for}{for =fx61, =fx62}[[Image:Fx61settings-CookiesAndSiteData]]{/for} +#* If you are troubleshooting problems with websites, make sure that '''Accept third-party cookies and site data''' is NOT set to '''Never'''. For more information, see [[Disable third-party cookies in Firefox to stop some types of tracking by advertisers]]. +# Choose how long cookies are allowed to be stored: +#* Keep until:
{for =fx60}'''they expire'''{/for}{for fx61}'''They expire'''{/for}: Each cookie will be removed when it reaches its expiration date, which is set by the site that sent the cookie.
{for =fx60}'''I close Firefox'''{/for}{for fx61}'''Firefox is closed'''{/for}: The cookies that are stored on your computer will be removed when Firefox is closed. +# [[T:closeOptionsPreferences]] +{/for} +{for =fx63, =fx64} +# [[T:optionspreferences]] +# Select the {menu Privacy & Security} panel and go to the '''Cookies and Site Data''' section. +#;[[Image:Fx63settings-AcceptCookies]] +# Select '''Accept cookies and site data''' to enable cookies. To disable cookies, select '''Block cookies and site data''' and use the drop-down menu next to '''Type blocked''' to choose the type of cookies to block. +#* If you are troubleshooting problems with websites, make sure that '''Accept third-party cookies and site data''' is NOT set to '''Never'''. For more information, see [[Disable third-party cookies in Firefox to stop some types of tracking by advertisers]]. +# Choose how long cookies are allowed to be stored: +#* Keep until:
'''They expire''': Each cookie will be removed when it reaches its expiration date, which is set by the site that sent the cookie.
'''Firefox is closed''': The cookies that are stored on your computer will be removed when Firefox is closed. +# [[T:closeOptionsPreferences]] +{/for} + +{for fx65} +Click the menu button [[Image:fx57menu]] and select {menu Content Blocking}. The {menu Privacy & Security} panel of Firefox [[T:optionsorpreferences]] will open. This is where you can view your settings for '''Content Blocking''', which includes cookies. +;[[Image:fx65ContentBlocking]] +*If {menu Standard} is selected, it means that you are using the default settings for content blocking and cookies are enabled. + +'''To block cookies''': +Select {menu Custom} and check mark '''Cookies'''. +;[[Image:Fx65Custom-ThirdPartyCookies]] +''Third-Party Trackers'' is the default setting for blocking cookies. Use the drop-down menu to change the type of cookies blocked. Note that disabling cookies can cause problems with websites. See [[Disable third-party cookies in Firefox to stop some types of tracking by advertisers|this article]] to learn more about third-party cookies. + +'''To enable all cookies''', do one of the following: +* Select {menu Custom} and clear the '''Cookies''' check mark. +* Alternatively, select {menu Standard} to restore the default settings. + +To learn more about these settings, see the [[Content blocking]] article. + += Clear cookies when you close Firefox = +To remove all cookies and site data when Firefox is closed: +#[[T:OptionsPreferences]] +#Select the {menu Privacy & Security} panel and go to the '''Cookies and Site Data''' section. +#;[[Image:Fx65CookiesAndSiteData]] +# Check mark ''Delete cookies and site data when Firefox is closed''. +Each time you close Firefox, the cookies that are stored on your computer will be removed. +{/for} + += Websites report cookie errors = +If a website gives you an error message that cookies must be enabled, make sure that you have not blocked cookies for the website. See [[Block websites from storing cookies and site data in Firefox]] and [[Websites say cookies are blocked - Unblock them]] for more information. \ No newline at end of file diff --git a/samples/Get started with Firefox - An overview of the main features.txt b/samples/Get started with Firefox - An overview of the main features.txt new file mode 100644 index 0000000..3e5a43a --- /dev/null +++ b/samples/Get started with Firefox - An overview of the main features.txt @@ -0,0 +1,145 @@ +Get started with Firefox - An overview of the main features + + +{for fx57}{warning}'''Got five minutes?''' Share your thoughts about Firefox by filling out this [https://qsurvey.mozilla.com/s3/Getting-Started-with-Firefox-SUMO-Survey?source=57 survey]. Thanks for your time!{/warning}{/for} +{for not fx57}{warning}'''Got five minutes?''' Share your thoughts about Firefox by filling out this [https://qsurvey.mozilla.com/s3/Getting-Started-with-Firefox-SUMO-Survey survey]. Thanks for your time!{/warning}{/for} + +Welcome to Firefox! We'll show you all the basics to get you up and running. When you're ready to go beyond the basics, check out the other links for features you can explore later. + +__TOC__ + +{for fx57} +=New Tab page: great content at your fingertips= +By default, Firefox gives you access to great content every time you open a new tab. Customize this page by hovering over the sections and thumbnails or click the gear icon for more options. +;[[Image:new tab page 57]] +{note} Want to learn more? See [[About the New Tab page]].{/note} + +=Search everything with the unified search/address bar= +Whether you know the exact web address or just searching, the unified ''Awesome Bar'' handles it all. Firefox's URL bar gives you suggestions based on your existing bookmarks and tags, history, open tabs, and popular searches. How's that for Awesome? Just start typing in a search or url and watch the magic happen. +;[[Image:awesome bar 57]] + +{note}Learn more search tricks with the [[Awesome Bar - Search your Firefox bookmarks, history and tabs from the address bar]].{/note} + +=Page actions menu: Bookmark, snap, save or share= +Find a really great web page? Save it or share it. The Page Actions menu in the address bar lets you [[Bookmarks in Firefox|bookmark]] web pages, copy or email links, take [[Firefox Screenshots|screenshots]], and [[View synced tabs from other devices|send pages to your phone]] or to your [https://getpocket.com/ Pocket] list so you can read them whenever and wherever you want. +;[[Image:page actions 57]] + +=Private Browsing with Tracking Protection: browse fast and free = +Browse the Internet without saving any information on your computer about which sites and pages you’ve visited. Firefox will also block creepy trackers that follow your behavior across the Web. +*Click the menu button [[Image:Fx57Menu]] and then click {button New Private Window}. ('''Tip:''' You can also {for win}right-click{/for}{for mac,linux}control + click{/for} on a link on a web page, then click {menu Open Link in New Private Window}.) +;{for win}[[Image:private mask 57 win]]{/for}{for mac}[[Image:private mask 57]]{/for}{for linux}[[Image:private mask 57 linux]]{/for} +{note}See [[Private Browsing - Use Firefox without saving history]] for more.{/note} + += Keep your Firefox in sync = +Set up Firefox Accounts so you can take your browsing information with you wherever you go. Click the menu button [[Image:Fx57Menu]], choose {button Sign in to Sync} and follow the instructions to create your account. Then sign in to the newly-created account on your other devices and that's it! +{note}For detailed instructions, see [[How do I set up Firefox Sync?]]{/note} + +=Home is just a click away= +''Choose the page that opens when you start Firefox or click the Home button.'' +# Open a tab with the web page you want to use as your home page. +# Drag and drop that tab onto the Home button [[Image:Home Button 57]]. +#;[[Image:set homepage 57]] +{note}More options can be found in the [[How to set the home page]] article.{/note} + += Customize the menu or the toolbar = +We've streamlined the toolbar with the most popular features but Firefox has even more features tucked away. Take a peek! +#Click the menu button [[Image:Fx57Menu]] and choose {button [[Image:57customize-icon.png]] Customize…}. +#Drag and drop the features you want onto your toolbar or the panel on the right. +#;[[Image:customize drag 57]] +#When you are done, click the {button Done} button. +{note}Learn more about [[Customize Firefox controls, buttons and toolbars|customizing Firefox]].{/note} +{/for} + +{for not fx57} += Set or change your home page = +''Choose the page that opens when you start Firefox or click the Home button.'' + +[[Video:http://youtu.be/Nnu0A-jIh-U]] +# Open a tab with the webpage you want to use as your home page. +# Drag and drop that tab onto the Home button [[Image:Home Button]]. +#;{for win}[[Image:Home Page 29 - Win8]]{/for}{for mac}[[Image:Home Page 29 - Mac]]{/for}{for linux}[[Image:Home Page 29 - Linux]]{/for} +# Click {button Yes} to set this as your home page. +More options can be found in the [[How to set the home page|home page article]]. + += Search the web = +''Pick your favorite search engine with Firefox's built-in Search bar.'' +* Just start typing into the search bar and pick the search engine you want. +*;{for win}[[Image:quick search win]]{/for}{for mac}[[Image:quick search fx34]]{/for}{for linux}[[Image:quick search linux Y]]{/for} + +Learn more search tricks with the [[Search bar - Easily choose your favorite search engine|Search bar article]]. + += Bookmark a website = +''Save your favorite sites.'' + +[[Video:http://youtu.be/F3uMpJ0YzqM]] +* To create a bookmark, click the star in the toolbar. The star will turn blue and a bookmark for the page you're on will be created in the {for not fx48}Unsorted Bookmarks{/for}{for fx48}Other Bookmarks{/for} folder. That's it! +*;{for win}[[Image:Bookmark 29 Win]]{/for}{for mac}[[Image:Bookmark 29 Mac]]{/for}{for linux}[[Image:Bookmark 29 Lin]]{/for} +{note}'''Tip:''' Drag a tab directly to your [[Create bookmarks to save your favorite webpages#w_how-do-i-turn-on-the-bookmarks-toolbar|bookmarks toolbar]] to save it there. {/note} +For more information, see the [[Create bookmarks to save your favorite webpages|bookmarks article]]. + += Find everything with the Awesome Bar = +''We like to call Firefox’s address bar the "Awesome Bar" because it quickly finds places you've visited before.'' + +[[Video:http://youtu.be/U7stmWKvk64]] +* Start typing in the address bar and you'll see a list of pages from your browsing history and bookmarks. When you see the page you want, just click on it. +*;{for win}[[Image:Bookmark3 29 Win]]{/for}{for mac}[[Image:Bookmark3 29 Mac]]{/for}{for linux}[[Image:Bookmark3 29 Lin]]{/for} +{note}'''Tip:''' You can also do a web search from here. Give it a try.{/note} +To learn more tricks, see the [[Search your bookmarks, history and tabs with the Awesome Bar|Awesome Bar article]]. + += Private Browsing = +''Firefox’s Private Browsing feature allows you to browse the Internet without saving any information on your computer about which sites and pages you’ve visited.'' + +[[Video:http://youtu.be/r3s-zDwLjb0]] +*Click the menu button [[Image:New Fx Menu]] and then click {button New Private Window}. +*;{for winxp}[[Image:private browsing - fx29 - winxp]]{/for}{for win7,win8,win10}[[Image:private browsing - fx29 - win8]]{/for}{for mac}[[Image:private browsing - fx29 - mac]]{/for}{for linux}[[Image:private browsing button - linux]]{/for} +Learn more about how [[Private Browsing - Browse the web without saving information about the sites you visit|Private Browsing]] works. + += Customize the menu or the toolbar = +''You can change the items that appear in the menu or your toolbar.'' + +[[Video:http://youtu.be/94tAqUObEfc]] +#Click the menu button [[Image:new fx menu]] and choose {button Customize}. +#*A special tab will open which allows you to drag and drop items in or out of the menu and the toolbar. +#;{for win,mac}[[Image:Customize Fx 29 Win8]]{/for}{for linux}[[Image:Customize Fx 29 Linux]]{/for} +#When you are done, click the green {button Exit Customize} button. +Learn more about [[Customize Firefox controls, buttons and toolbars|customizing Firefox]]. + += Add features to Firefox with add-ons = +''Add-ons are like apps that you can install to make Firefox work the way you want.'' +{for not fx48} + +[[Video:http://youtu.be/i4y_CeifV2s]] +# [[T:Open Add-ons|type=Get Add-ons]] +# To see more information on a Featured Add-on or Theme, click it. You can then click the green {button Add to Firefox} button to install it. +#*You can also search for specific add-ons by using the search box at the top. You can then install any add-ons you find with the {button Install} button. +#*;{for win}[[Image:Addon1 29 Win]][[Image:Addon2 29 Win]]{/for}{for mac}[[Image:Addon1 29 Mac]][[Image:Addon2 29 Mac]]{/for}{for linux}[[Image:Addon1 29 Lin]][[Image:Addon2 29 Lin]]{/for} +#Firefox will download the requested add-on and may ask you to confirm that you want to install it. +# Click {button Restart Now} if it pops up. Your tabs will be saved and restored after the restart. +{/for} +{for fx48} +# [[T:Open Add-ons|type=Get Add-ons]] +# To install a featured add-on, click the grey toggle button, which will turn green. To uninstall an add-on you just installed, click the toggle button again. +#;{for win,mac}[[Image:Fx48-GetAddons]]{/for}{for linux}[[Image:Fx48-GetAddons-Linux]]{/for} + +At the bottom of the list of featured add-ons, there's a {button See more add-ons!} button you can click. It will take you to addons.mozilla.org where you can search for specific add-ons. +{/for} +To learn more about add-ons, see [[Find and install add-ons to add features to Firefox]]. +{note}'''Tip:''' Some add-ons place a button in the toolbar after installation. You can remove those or move them into the menu if you want – see [[Customize Firefox controls, buttons and toolbars]].{/note} + += Keep your Firefox in sync = +''Access your bookmarks, history, passwords and more from any device.'' + +[[Video:http://youtu.be/wSVJrWzoq7E]] +#First create a Firefox account: +#*Click the menu button [[Image:New Fx Menu]] and choose {button Sign in to Sync} and follow the instructions to create your account. +#;{for win,mac}[[Image:Sync 29]]{/for}{for linux}[[Image:Sync in menu Linux]]{/for} +#Then just sign in to connect another device. +For detailed instructions, see [[How do I set up Firefox Sync?]] +{/for} + += Get help = +''If you have more questions or ever need help with Firefox, you're on the right website.'' +*[/products/firefox This site] has hundreds of articles that cover nearly every Firefox question you might have. +;[[Image:Get Help|link=/products/firefox]] + +[[Template:top5afterword]] \ No newline at end of file diff --git a/samples/Refresh Firefox - reset add-ons and settings.txt b/samples/Refresh Firefox - reset add-ons and settings.txt new file mode 100644 index 0000000..e83b5e9 --- /dev/null +++ b/samples/Refresh Firefox - reset add-ons and settings.txt @@ -0,0 +1,47 @@ +Refresh Firefox - reset add-ons and settings +[[Template:desktoponly]] + +If you're having problems with Firefox, refreshing it can help. The refresh feature fixes many issues by restoring Firefox to its default state while saving your essential information like bookmarks, passwords, and open tabs. {note}'''Important:''' Since Firefox will revert to its original state, your own configurations and customizations, including [[Find and install add-ons to add features to Firefox#w_what-types-of-add-ons-can-i-install|extensions]], extension data, and about:config [[Configuration Editor for Firefox|preference configurations]] are removed. If you've made accessibility configurations, you may need to change them back after refreshing.{/note} + += Refresh Firefox = +[[T:resetsteps]] + += What does the refresh feature do? = +All of your Firefox settings and personal information are stored in a [[Profiles - Where Firefox stores your bookmarks, passwords and other user data|profile folder]]. The refresh feature works by creating a new profile folder for you while saving your important data. + +Add-ons which are normally stored inside the Firefox profile folder, such as [https://addons.mozilla.org/firefox/extensions/ extensions] and [[Use themes to change the look of Firefox|themes]], will be removed. Add-ons stored in other locations{for not fx53}, such as [[Use plugins to play audio, video, games and more |plugins]],{/for} will not be removed but any modified preferences{for not fx53} (such as plugins you have disabled){/for} will be reset. + +== Firefox will save these items: == +*Bookmarks +*Browsing and download history +*Passwords +*Open windows and tabs +*Cookies +*Web form auto-fill information +*Personal dictionary + +== These items and settings will be removed: == +*[[Find and install add-ons to add features to Firefox|Extensions and themes]] +*Website permissions +*Modified preferences +*[[Add or remove a search engine in Firefox#w_add-a-search-engine|Added search engines]] +*DOM storage +{for not fx56} +*[[Advanced panel - Accessibility, browsing, network, updates, and other advanced settings in Firefox#w_certificates-tab|Security certificate and device settings]] +{/for} +{for fx56} +*[[Secure Website Certificate|Security certificate]] and device settings +{/for} +*[[Change what Firefox does when you click on or download a file|Download actions]] +{for not fx53} +*Plugin settings +{/for} +*[[Customize Firefox controls, buttons and toolbars|Toolbar customizations]] +{for not fx57} +*[[Add social features to the Firefox sidebar|Social features]] +{/for} +*User styles ({filepath chrome} subfolder containing {filepath userChrome} and/or {filepath userContent} [https://wikipedia.org/wiki/Cascading_Style_Sheets CSS files], if previously created.) + +{note}'''Note:''' Your old Firefox profile will be placed on your desktop in a folder named "Old Firefox Data". If the {for not fx35}reset{/for}{for fx35}refresh{/for} didn't fix your problem you can restore some of the information not saved by [[Recovering important data from an old profile#w_copying-files-between-profile-folders|copying files to the new profile that was created]]. If you don't need this folder any longer, you should delete it as it contains sensitive information.{/note} + +[[Template:top5afterword]] \ No newline at end of file diff --git a/samples/What do the security warning codes mean.txt b/samples/What do the security warning codes mean.txt new file mode 100644 index 0000000..39f3079 --- /dev/null +++ b/samples/What do the security warning codes mean.txt @@ -0,0 +1,151 @@ +What do the security warning codes mean? +When Firefox connects to a secure website (the URL begins with "http'''s'''://"), it must verify that the certificate presented by the website is valid and that the encryption is strong enough to adequately protect your privacy. If it is unable to verify this, Firefox stops connecting to the site and will show you an error page with the message, {for not fx66}''Your connection is not secure''{/for}{for fx66}''Warning: Potential Security Risk Ahead''{/for}. + +{for not fx66}[[Image:Fx52InsecureConnection]]{/for}{for fx66}[[Image:Fx66Warning-SecurityRisk]]{/for} + +Click the {button Advanced} button to view the error code and other information about the error. Common errors are described in this article. + +* If Firefox shows you a ''Secure Connection Failed'' {for fx66}or ''Did Not Connect: Potential Security Issue''{/for} error page instead, see [[Troubleshoot the "Secure Connection Failed" error message|this article]]. + +__TOC__ + +{for fx66} +=What to do if you see these errors?= +If you see a ''Warning: Potential Security Risk Ahead'' message, you may: +*Contact the website owner and ask them to correct their certificate. +*Click {button Go Back (Recommended)}, or visit a different website. +*If you are on a corporate network or using antivirus software, reach out to the support teams for assistance. +After viewing the error code and other information about the error, click the {button Accept the Risk and Continue} button to load the site at your own risk. This will add a security exception for the website certificate. + +{warning}'''Warning!''' Do not proceed to the website unless you understand the reasons for the security warning. Legitimate public sites will '''not''' require you to add a security exception for their certificate. An invalid certificate can be an indication of a web page that will defraud you or steal your identity.{/warning} + +=MOZILLA_PKIX_ERROR _ADDITIONAL_POLICY_CONSTRAINT_FAILED= + +This error indicates that the website's certificate has not complied with security policies in [https://wiki.mozilla.org/CA Mozilla's CA Certificate Program]. Most browsers, not just Firefox, do not trust certificates by GeoTrust, RapidSSL, Symantec, Thawte, and VeriSign because these certificate authorities failed to follow security practices in the past. + +The owners of the website need to work with their certificate authority to correct the policy problem. Mozilla's CA Certificate Program publishes a list of [https://wiki.mozilla.org/CA/Upcoming_Distrust_Actions upcoming policy actions affecting certificate authorities] which contains details that might be useful to the website owners. + +For more information, see the Mozilla Security Blog post, [https://blog.mozilla.org/security/2018/03/12/distrust-symantec-tls-certificates/ Distrust of Symantec TLS Certificates]. + +=SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE= +The certificate will not be valid until ''date'' (...)
+ +The error text will also show the current date and time of your system. In case this is incorrect, set your system clock to today's date and time{for win} (double-click the clock icon on the Windows Taskbar){/for} in order to fix the problem. More details about this are available in the support article [[How to troubleshoot time related errors on secure websites]]. + +=SEC_ERROR_EXPIRED_CERTIFICATE= +The certificate expired on ''date'' (...)
+This error occurs when a website's identity certification has expired. + +The error text will also show the current date and time of your system. In case this is incorrect, set your system clock to today's date and time{for win} (double-click the clock icon on the Windows Taskbar){/for} in order to fix the problem. More details about this are available in the support article [[How to troubleshoot time related errors on secure websites]]. + +=SEC_ERROR_UNKNOWN_ISSUER= +The certificate is not trusted because the issuer certificate is unknown.
The server might not be sending the appropriate intermediate certificates.
An additional root certificate may need to be imported.
+ +=MOZILLA_PKIX_ERROR_MITM_DETECTED= +The certificate is not trusted because the issuer certificate is unknown.
The server might not be sending the appropriate intermediate certificates.
An additional root certificate may need to be imported. + +MOZILLA_PKIX_ERROR_MITM_DETECTED is a special case of the SEC_ERROR_UNKNOWN_ISSUER error code when a [https://developer.mozilla.org/docs/Glossary/MitM man-in-the-middle attack] is detected. + +You may have enabled SSL scanning in your security software such as Avast, Bitdefender, ESET or Kaspersky. Try to disable this option. More details are available in the support article [[How to troubleshoot security error codes on secure websites]]. + +{for win8,win10} +You may also see this error message on major sites like Google, Facebook, YouTube and others on Windows in user accounts protected by Microsoft family settings. To turn these settings off for a particular user, see the Microsoft support article [http://go.microsoft.com/fwlink/p/?LinkId=627342 How do I turn off family features?]. +{/for} + +=ERROR_SELF_SIGNED_CERT= +The certificate is not trusted because it is self-signed. + +Self-signed certificates make your data safe from eavesdroppers, but say nothing about who the recipient of the data is. This is common for intranet websites that aren't available publicly and you may bypass the warning for such sites. More details are available in the support article [[How to troubleshoot security error codes on secure websites]]. + +=SSL_ERROR_BAD_CERT_DOMAIN= +Firefox does not trust this site because it uses a certificate that is not valid for that particular site. Information sent over this site could be at risk, so the best thing for you to do is contact the website owners to correct the problem. + +=SEC_ERROR_OCSP_INVALID_SIGNING_CERT= +The site is not configured correctly and failed a security check. If you visit this site, attackers could try to steal your private information, like passwords, emails, or credit card details. + +The issue is with the website, and there is nothing you can do to resolve it. You can notify the website’s administrator about the problem. + +=Corrupted certificate store= +You may also see certificate error messages when the file in your profile folder that stores your certificates {filepath cert9.db} has become corrupted. Try to delete this file while Firefox is closed to regenerate it: +{note}'''Note:''' You should only perform these steps as a last resort, after all other troubleshooting steps have failed.{/note} +#[[T:profileFolder]] +#[[T:closeFirefox]] +# Click on the file named {filepath cert9.db}. +# Press {for mac}{key command}+{/for}{key Delete}. +# Restart Firefox. +;{note}'''Note:''' {filepath cert9.db} will be recreated when you restart Firefox. This is normal.{/note} +{/for} +{for not fx66} += What to do if you see this error? = +If you encounter a "Your connection is not secure" error, you should contact the owners of the website, if possible, and inform them of the error. It is recommended that you wait for the website to be fixed before using it. The safest thing to do is to click {button Go Back}, or to visit a different website. Unless you know and understand the technical reason why the website presented incorrect identification, and are willing to risk communicating over a connection that could be vulnerable to an eavesdropper, you should not proceed to the website. + += Technical information = +Click on {button Advanced} for more information on why the connection is not secure. Some common errors are described below: + +== Certificate does not come from a trusted source == +{note}The certificate does not come from a trusted source.

Error code: MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED{/note} + +This error indicates that [https://wiki.mozilla.org/CA Mozilla's CA Certificate Program] has imposed policies upon this website's certificate authority that the website has not complied with. When this error occurs, it indicates that the owners of the website need to work with their certificate authority to correct the policy problem. + +Mozilla's CA Certificate Program publishes a list of [https://wiki.mozilla.org/CA/Upcoming_Distrust_Actions upcoming policy actions affecting certificate authorities] which contains details that might be useful to the website owners. +For more information, see the Mozilla Security Blog post, [https://blog.mozilla.org/security/2018/03/12/distrust-symantec-tls-certificates/ Distrust of Symantec TLS Certificates]. + +== The certificate will not be valid until ''(date)'' == +{note}The certificate will not be valid until ''date'' (...)

Error code: SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE{/note} + +The error text will also show the current date and time of your system. In case this is incorrect, set your system clock to today's date and time{for win} (double-click the clock icon on the Windows Taskbar){/for} in order to fix the problem. More details about this are available in the support article [[How to troubleshoot time related errors on secure websites]]. + +== The certificate expired on ''(date)'' == +{note}The certificate expired on ''date'' (...)

Error code: SEC_ERROR_EXPIRED_CERTIFICATE{/note} + +This error occurs when a website's identity certification has expired. + +The error text will also show the current date and time of your system. In case this is incorrect, set your system clock to today's date and time{for win} (double-click the clock icon on the Windows Taskbar){/for} in order to fix the problem. More details about this are available in the support article [[How to troubleshoot time related errors on secure websites]]. + +== The certificate is not trusted because the issuer certificate is unknown == +{note}The certificate is not trusted because the issuer certificate is unknown.
The server might not be sending the appropriate intermediate certificates.
An additional root certificate may need to be imported.

Error code: SEC_ERROR_UNKNOWN_ISSUER{/note} + +{note}The certificate is not trusted because the issuer certificate is unknown.
The server might not be sending the appropriate intermediate certificates.
An additional root certificate may need to be imported.

Error code: MOZILLA_PKIX_ERROR_MITM_DETECTED{/note} + +MOZILLA_PKIX_ERROR_MITM_DETECTED is a special case of the SEC_ERROR_UNKNOWN_ISSUER error code when a [https://developer.mozilla.org/docs/Glossary/MitM man-in-the-middle attack] is detected. + +You may have enabled SSL scanning in your security software such as Avast, Bitdefender, ESET or Kaspersky. Try to disable this option. More details are available in the support article [[How to troubleshoot security error codes on secure websites]]. + +{for win8,win10} +You may also see this error message on major sites like Google, Facebook, YouTube and others on Windows in user accounts protected by Microsoft family settings. To turn these settings off for a particular user, see the Microsoft support article [http://go.microsoft.com/fwlink/p/?LinkId=627342 How do I turn off family features?]. +{/for} + +== The certificate is not trusted because it is self-signed == +{note}The certificate is not trusted because it is self-signed. +

Error code: ERROR_SELF_SIGNED_CERT{/note} + +Self-signed certificates make your data safe from eavesdroppers, but say nothing about who the recipient of the data is. This is common for intranet websites that aren't available publicly and you may bypass the warning for such sites. More details are available in the support article [[How to troubleshoot security error codes on secure websites]]. + +== The certificate is only valid for ''(site name)'' == +{note}example.com uses an invalid security certificate.

The certificate is only valid for the following names: www.example.com, *.example.com +

Error code: SSL_ERROR_BAD_CERT_DOMAIN{/note} + +This error is telling you that the identification sent to you by the site is actually for another site. While anything you send would be safe from eavesdroppers, the recipient may not be who you think it is. + +A common situation is when the certificate is actually for a different part of the same site. For example, you may have visited https://example.com, but the certificate is for https://'''www.'''example.com. In this case, if you access https://'''www.'''example.com directly, you should not receive the warning. + +== Corrupted certificate store == +You may also see certificate error messages when the file in your profile folder that stores your certificates ({for not fx58}{filepath cert8.db}{/for}{for fx58}{filepath cert9.db}{/for}) has become corrupted. Try to delete this file while Firefox is closed to regenerate it: +{note}'''Note:''' You should only perform these steps as a last resort, after all other troubleshooting steps have failed.{/note} +#[[T:profileFolder]] +#[[T:closeFirefox]] +# Click on the file named {for not fx58}{filepath cert8.db}{/for}{for fx58}{filepath cert9.db}{/for}. +# Press {for mac}{key command}+{/for}{key Delete}. +# Restart Firefox. +;{note}'''Note:''' {for not fx58}{filepath cert8.db}{/for}{for fx58}{filepath cert9.db}{/for} will be recreated when you restart Firefox. This is normal.{/note} + += Bypassing the warning = +{note}'''Note:''' Some security warnings cannot be bypassed.{/note} +You should only bypass the warning if you're confident in both the identity of the website and the integrity of your connection - even if you trust the site, someone could be tampering with your connection. Data you enter into a site over a weakly encrypted connection can be vulnerable to eavesdroppers as well. + +In order to bypass the warning page, click {button Advanced}: +* On sites with a weak encryption you will then be shown an option to load the site using outdated security. +* On sites where the certificate cannot be validated, you might be given the option to add an exception. + +{warning}Legitimate public sites will '''not''' ask you to add an exception for their certificate - in this case an invalid certificate can be an indication of a web page that will defraud you or steal your identity.{/warning} +{/for} \ No newline at end of file diff --git a/samples/content blocking.txt b/samples/content blocking.txt new file mode 100644 index 0000000..491745a --- /dev/null +++ b/samples/content blocking.txt @@ -0,0 +1,222 @@ +Content blocking + + +{for not fx63}[[T:update fx desktop]]{/for} +{for fx67} +Content blocking is a collection of Firefox privacy features that protect you from threats and annoyances on the Web. This includes protections against trackers, which collect your browsing data across multiple websites. Starting with Firefox version 67, you can block harmful scripts including cryptominers and fingerprinters. + +In some cases, blocking this content makes pages load faster, but can affect the page's functionality. It’s easy to [[#w_turn-content-blocking-off-on-individual-sites|disable blocking on sites you trust]]. You can also customize your content blocking preferences to [[#w_how-to-block-more-or-fewer-trackers|block more or fewer trackers]]. +{/for} + +{for not fx67} +Some websites use trackers that can monitor your activity across the Internet. Content blocking is a collection of Firefox settings that block many of these third-party trackers. It keeps your browsing more private so information about you won’t be invisibly tracked, stored, and shared between websites. + +In some cases, blocking trackers keeps parts of pages or entire pages from loading. It’s easy to [[#w_turn-content-blocking-off-on-individual-sites_2|disable blocking on sites you trust]]. You can also customize your content blocking preferences to [[#w_how-to-block-more-or-fewer-trackers_2|block more or fewer trackers]]. +{/for} + +{for not fx65} +Content blocking is a collection of Firefox settings, allowing you to block content that affects privacy and browsing performance. Starting with [[Find what version of Firefox you are using|Firefox version]] 63, you can block third-party tracking cookies and all detected trackers (previously known as Tracking Protection). +{/for} + +__TOC__ + +{for fx67} +=Privacy protections included in content blocking= +*Trackers: Tracking generally refers to content, cookies, or scripts that can collect your browsing data across multiple sites. Firefox blocks trackers in private windows by default. Select the '''Strict''' or '''Custom''' radio button for stronger tracking protections. +*Third-party tracking cookies: Third-party cookies are cookies that are set by a website other than the one you are currently on. Block third-party tracking cookies using the '''Strict''' and '''Custom''' radio buttons in Firefox version 67. +*Cryptominers: Cryptomining scripts use your computer’s central processing unit (CPU) to invisibly mine cryptocurrency. These scripts slow down your computer and drain your battery. Block cryptominers using the '''Custom''' radio button in Firefox version 67. +*Fingerprinters: Fingerprinting scripts are invisibly embedded on many web pages, harvesting a snapshot of your computer’s configuration to build a digital fingerprint that can be used to track you across the web even if you clear your cookies. Fingerprinting violates Firefox’s anti-tracking policy. Block fingerprinters using the '''Custom''' radio button in Firefox version 67. + +=How to block more or fewer trackers= +By default, Firefox protects you from being tracked in [[Private Browsing - Use Firefox without saving history|private windows]] using a basic list of known trackers provided by [https://disconnect.me/trackerprotection Disconnect]. Firefox allows some trackers so websites can function properly. You can change your settings to block trackers all the time, to block trackers from Disconnect’s strict list, or to not block any trackers at all. + +To adjust your settings: +#Click the menu button [[Image:fx57menu]]. +#Click {menu Content Blocking}.
This takes you to the ''Content Blocking'' section in your Firefox [[T:optionsorpreferences]] Privacy & Security panel. +#;[[Image:Content Blocking]] +#Choose your content blocking settings: +*'''Standard''': Only blocks known trackers in private windows. This is the default setting. To restore to defaults at anytime, select '''Standard'''. +*'''Strict''': Blocks trackers in all windows and third-party tracking [[Cookies - Information that websites store on your computer|cookies]]. +*'''Custom''': Lets you choose what to block. You can also turn off all content blocking using the '''Custom''' radio button. + +You can also set Firefox to always send websites a ''Do Not Track'' signal. See [[How do I turn on the Do Not Track feature?]] to learn more. + +'''Custom settings:''' +==Set Aggressive Tracking Protection== +#Select '''Custom'''. +#Select {menu In all windows} from the drop-down on the right. +#;[[Image:Tracking Protection]] +#Click the '''Change block list''' link.
The ''Block Lists'' pop-up displays. +#Select {menu Level 2 block list. Blocks all detected trackers. Some websites or content may not load properly}. +#Click {button Save Changes}. +#Select the '''Cookies''' checkbox if not already selected.
{menu Third-Party Trackers} is selected by default. Select more aggressive cookie protections from the dropdown, such as blocking all third-party cookies or even blocking all cookies. +#Select the '''Cryptominers''' checkbox. +#Select the '''Fingerprinters''' checkbox. +#Click the {button Reload All Tabs} button to apply these changes on all your open tabs. + +==Remove all protections== +You can also remove all the protections offered by content blocking, which effectively disables the feature. +#Select the '''Custom''' radio button. +#Deselect the '''Trackers''' checkbox. +#Deselect the '''Cookies''' checkbox. +#Deselect the '''Cryptominers''' checkbox. +#Deselect the '''Fingerprinters''' checkbox. +#Click the {button Reload All Tabs} button to apply these changes on all your open tabs. + +=How to detect when content blocking is on= +When Firefox is blocking content on a website, a shield icon [[Image:Address bar shield]] will appear in your address bar. +;[[Image:url shield 65]] +[[Template:controlcenterpanel]] View the Content Blocking section. This provides more information about the type of content Firefox is blocking, such as detected trackers and trackers set by third-party tracking cookies. +;[[Image:content blocking panel 65]] +The content that is blocked will depend on the website and your settings. Click on the arrows "'''>'''" to the right of the ''Trackers'' and ''Cookies'' settings to see what content has been blocked or permitted on the specific site you're on. +;[[Image:blocked cookies 65]] +Blocked content will be labeled as ''Blocked'' and grayed out. + +=Turn content blocking off on individual sites= +Sometimes content blocking can prevent pages or parts of pages from loading. If content blocking interferes with your browsing, you can disable it on individual sites. The shield icon appears in the address bar when Firefox is actively blocking content on a page. +#[[Template:controlcenterpanel]] +#;[[Image:content blocking panel 65]] +#Click the {button Turn off Blocking for This Site} button from a normal browsing window to disable blocking for the website.
If you're in a private window, click the {button Turn off Blocking Temporarily} button (see below).
Once content blocking is disabled, a shield icon with a strikethrough [[Image:shield icon strikethrough]] will appear in your address bar. To turn content blocking back on, expand the Control Center panel by clicking the shield or the {button site information} button [[Image:site info icon]] and click the {button Turn on Blocking for This Site} button. + +=Content Blocking in Private Browsing= +Since [[Private Browsing - Use Firefox without saving history|Private Browsing]] doesn’t save information about your browsing session, when you disable content blocking for a site, it will only remain disabled during your current private browsing session. When you start a new private browsing session, your content blocking settings will be restored for all sites. If you’ve disabled content blocking for a site while in a normal browsing window, Firefox will continue to disable content blocking for this same site when in a private window. + +=Block lists in Firefox= +By default, Firefox uses the [https://disconnect.me Disconnect.me] Level 1 block list. For more aggressive tracking protection, use the Disconnect.me Level 2 block list. +*Level 1 blocks commonly known analytics trackers, social sharing trackers, and advertising trackers. However, the basic protection list allows some known content trackers so that fewer pages break or fail to load. +*Level 2 list blocks all known trackers, including analytics trackers, social sharing trackers, and advertising trackers as well as content trackers. The strict list will break some videos, photo slideshows, and social networking features. + +==Change your block list== +#Click the menu button [[Image:fx57menu]]. +#Click {menu Content Blocking}.
This takes you to the ''Content Blocking'' section in your Firefox [[T:optionsorpreferences]] Privacy & Security panel. +#Select the '''Custom''' radio button. +#Click the '''Change block list''' link. +#Choose the block list you want to use. +#;[[Image:Change Block Lists]] +#Click {button Save Changes}. +{/for} + +{for not fx67} +=How to block more or fewer trackers= +By default, Firefox protects you from being tracked in [[Private Browsing - Use Firefox without saving history|Private Windows]] using a basic list of known trackers provided by [https://disconnect.me/trackerprotection Disconnect]. Firefox allows some trackers so websites can function properly. You can change your settings to block trackers all the time, to block trackers from Disconnect’s strict list, or to not block any trackers at all. + +To adjust your settings: +#Click the menu button [[Image:fx57menu]]. +#Click {menu Content Blocking}.
This takes you to the Content Blocking section in your Firefox [[T:optionsorpreferences]] Privacy & Security panel. +#;[[Image:Fx65ContentBlocking]] +#Choose your content blocking settings: +*'''Standard''': Only blocks known trackers in Private Windows. This is the default setting. To restore to defaults at anytime, select the '''Standard''' radio button. +*'''Strict''': Blocks trackers in all windows and third-party tracking [[Cookies - Information that websites store on your computer|cookies]]. +*'''Custom''': Lets you choose what to block. You can also turn off all content blocking using the '''Custom''' radio button. + +You can also set Firefox to always send websites a ''Do Not Track'' signal. See [[How do I turn on the Do Not Track feature?]] to learn more. + +'''Custom settings:''' +==Aggressive Tracking Protection== +#Select '''Custom'''. +#Select {menu In all windows} from the drop-down on the right. +#;[[Image:content block custom all windows]] +#Click the '''Change block list''' link. +#Select the '''Disconnect.me strict protection''' checkbox. +#Click {button Save Changes}. +#Select '''Cookies'''.
''Third-Party Trackers'' is the default setting. Select more aggressive cookie protections from the dropdown, such as blocking all third-party cookies or even blocking all cookies. +#*For more information about blocking cookies, see [[Disable third-party cookies in Firefox to stop some types of tracking by advertisers|this article]]. + +==Remove all protections== +You can also remove all the protections offered by Content Blocking, which effectively disables the feature. +#Select the '''Custom''' radio button. +#Deselect the '''Trackers''' checkbox. +#Deselect the '''Cookies''' checkbox. + +=How to detect when content blocking is on= +When Firefox is blocking content on a website, a shield icon [[Image:Address bar shield]] will appear in your address bar. +;[[Image:url shield 65]] +[[Template:controlcenterpanel]] This provides more information about the content Firefox is blocking, such as trackers or third-party tracking cookies. +;[[Image:content blocking panel 65]] +The content that is blocked will depend on the website and your settings. Click on the arrows "'''>'''" to the right of ''Trackers'' and ''Cookies'' to see what content has been blocked or permitted on the specific site that you're on. +;[[Image:blocked cookies 65]] +Blocked content will be labeled as ''Blocked'' and grayed out. + +=Turn content blocking off on individual sites= +The shield icon [[Image:Address bar shield]] appears in the address bar when Firefox is actively blocking content on a page. Sometimes content blocking can prevent pages or parts of pages from loading. If content blocking interferes with your browsing, you can disable it on individual sites. +#[[Template:controlcenterpanel]] +#;[[Image:content blocking panel 65]] +#Click the {button Turn off Blocking for This Site} button to disable blocking for the website in a normal browsing window. If you're in a private window, click the {button Turn off Blocking Temporarily} button (see below). +#*Once Content Blocking is disabled, a shield icon with a strikethrough [[Image:shield icon strikethrough]] will appear in your address bar. +#To turn content blocking back on, expand Control Center panel by clicking the shield or the site information button [[Image:site info icon]] and click the {button Turn on Blocking for This Site} button. + +=Content Blocking in Private Browsing= +Since [[Private Browsing - Use Firefox without saving history|Private Browsing]] doesn’t save information about your browsing session, when you disable content blocking for a site, it only lasts for your current session. When you start a new private browsing session, your content blocking settings will be restored for all sites. If you’ve disabled content blocking for a site while in a normal browsing window, Firefox will continue to disable content blocking for this same site when in a private window. + +=Block lists in Firefox= +You can change the block list used to block trackers. By default, content blocking uses the [https://disconnect.me Disconnect.me] basic protection list. You can change this to use the Disconnect.me strict protection list instead. +*The basic protection list blocks commonly known analytics trackers, social sharing trackers, and advertising trackers. However, the basic protection list allows some known content trackers so that fewer pages break or fail to load. +*The strict protection list blocks all known trackers, including analytics trackers, social sharing trackers, and advertising trackers as well as content trackers. The strict list will break some videos, photo slideshows, and social networking features. + +==Change your block list== +#Click the menu button [[Image:fx57menu]]. +#Select {menu Content Blocking}. +#Select {menu Custom}. +#Click the '''Change block list''' link. +#Choose the block list you want to use. +#;{for not fx66}[[Image:Fx63BlockLists]]{/for}{for fx66}[[Image:Fx66BlockLists]]{/for} +#Click {button Save Changes}. +{/for} + +{for not fx65} +=Turn Content Blocking on or off= +Content blocking includes settings for trackers and tracking cookies. By default, Firefox blocks trackers only in [[Private Browsing - Use Firefox without saving history|private windows]] and doesn’t block third-party tracking cookies at all. You can change your {for win}options{/for}{for mac,linux}preferences{/for} to block trackers all the time or to not block any content at all. You can also set your {for win}options{/for}{for mac,linux}preferences{/for} to block just third-party tracking cookies or all third-party cookies. + +To change your {for win}options{/for}{for mac,linux}preferences{/for}, click the Firefox menu button [[Image:fx57menu]] and select {menu Content Blocking}. This takes you to your content blocking {for win}options{/for}{for mac,linux}preferences{/for}. + +[[Image:Fx63menuContentBlocking]] + +*To block trackers for all browsing sessions, change the ''All Detected Trackers'' setting from ''Only in private windows'' to ''Always''. +*To turn off Content Blocking for detected trackers, deselect the checkbox for ''All Detected Trackers''. +*Select the ''Third-Party Cookies'' checkbox to block third-party tracking cookies. To block all third-party cookies, change the setting from ''Trackers (recommended)'' to ''All third-party cookies (may cause websites to break)''. For more information, see [[Disable third-party cookies in Firefox to stop some types of tracking by advertisers]].
'''Note:''' You can also set Firefox to always send websites a ''Do Not Track'' signal. See [[How do I turn on the Do Not Track feature?]] to learn more. + +=How to detect when Content Blocking is on= +When Firefox is blocking content on a website, a shield [[Image:FirefoxShieldIcon]] icon will appear in your address bar. + +;[[Image:Fx63ContentBlockingURL]] + +Select the information [[Image:Site Info button]] icon or the shield [[Image:FirefoxShieldIcon]] icon to expand the [[Control Center - manage site privacy and security controls|Control Center]] for the site. This provides more information about the type of content Firefox has blocked, such as detected trackers and trackers set by third-party cookies. (The Control Center is also where you manage your permission settings for this site.) + +;[[Image:Fx63ContentBlocking-details]] + +If trackers or third-party tracking cookies are not found on a site, the Control Center will display the message "No blockable content detected on this page". + +;[[Image:no blockable content 63]] + +=Turn Content Blocking off on individual sites= +Sometimes content blocking can prevent pages or parts of pages from loading. If content blocking interferes with your browsing, you can disable it for the site you are visiting. The shield icon appears in the address bar when Firefox is actively blocking content on a page. +;[[Image:Fx63ContentBlockingURL]] +#Select the shield [[Image:FirefoxShieldIcon]] icon or the information [[Image:Site Info button]] icon to expand the Control Center panel. +#;[[Image:Fx63ContentBlocking-DisableBlocking]] +#Click the {button Disable Blocking for This Site} button in a normal browsing window or the {button Disable Blocking Temporarily} button in a [[Private Browsing - Use Firefox without saving history|private window]] (see below) to disable blocking for the website. +#Once content blocking is disabled, a shield icon with a strikethrough will appear in your address bar. +#;[[Image:blocking disabled 63]] +#To resume content blocking, expand the Control Center panel and select {button Enable Blocking For This Site}. + +=Content Blocking in Private Browsing= +Since [[Private Browsing - Use Firefox without saving history|Private Browsing]] doesn’t save information about your browsing session, when you disable content blocking for a site, it only lasts for your current session. When you start a new private browsing session, your content blocking settings will be restored for all sites. If you’ve disabled content blocking for a site while in a normal browsing window, Firefox will continue to disable content blocking for this same site when in a private window. + +==Turn Content Blocking on or off in private windows== +Content blocking is turned on by default in [[Private Browsing - Use Firefox without saving history|Private Browsing]] windows. + +[[Image:Fx63PrivateBrowsingHomePage-ContentBlockingON]] + +Click the switch next to content blocking on the Private Browsing home page to turn it off or back on. If you don't see a content blocking switch, it means that you've set Firefox to always block all detected trackers for all browsing sessions ([[#w_turn-content-blocking-on-or-off|see above]]). + +=Block lists in Firefox= +You can change the block list used to block trackers. By default, content blocking uses the Disconnect.me basic protection list. You can change this to use the Disconnect.me strict protection list instead. +*The basic protection list blocks commonly known analytics trackers, social sharing trackers, and advertising trackers. However, the basic protection list allows some known content trackers so that fewer pages break or fail to load. +*The strict protection list blocks all known trackers, including analytics trackers, social sharing trackers and advertising trackers as well as content trackers. The strict list will break some videos, photo slideshows, and social networking features. + +==Change your block list== +#Expand the main Firefox menu button [[Image:fx57menu]] and select {menu Content Blocking}. +#Click the '''Change block list''' link. +#Choose the block list you want to use. +#Click {button Save Changes}. +;[[Image:Fx63BlockLists]] +{/for} \ No newline at end of file diff --git a/test_wikiparser.py b/test_wikiparser.py index d43b1cb..0087233 100644 --- a/test_wikiparser.py +++ b/test_wikiparser.py @@ -4,9 +4,10 @@ import pytest import unittest import WikiParser +import re # -# Tests for the verification of parsing input files.. +# Tests for the verification of parsing input files. # class TestWikiParser(unittest.TestCase): @@ -46,3 +47,222 @@ def test_valid_inputfile_txt(self): assert self.dut.getInputFilename() == expectedFilename + ##### Now lets test the parsing of some simple lines ### + + def test_template_for_not_fx67(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\d+\-\d+" + + inputLine = {"originalLine": "{for not fx67}", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_template_slash_for(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\d+\-\d+" + + inputLine = {"originalLine": "{/for}", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_template_note(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\d+\-\d+" + + inputLine = {"originalLine": "{note}", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_template_slash_note(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\d+\-\d+" + + inputLine = {"originalLine": "{/note}", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_template_triple_quotes(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\d+\-\d+" + + inputLine = {"originalLine": "'''Note:'''", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_link_with_desription(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\[\[\s+\d+\-\d+\s+\|Firefox\s+version\]\]" + + inputLine = {"originalLine": "[[Find what version of Firefox you are using|Firefox version]]", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_brackets_http(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "Mozilla\'s\s*CA\s*Certificate\s*Program\s*publishes\s*a\s*list\s*of\s*\d+\-\d+\s*which\s*contains\s*details\s*that\s*might\s*be\s*useful\s*to\s*the\s*website\s*owners\." + + inputLine = {"originalLine": "Mozilla's CA Certificate Program publishes a list of [https://wiki.mozilla.org/CA/Upcoming_Distrust_Actions upcoming policy actions affecting certificate authorities] which contains details that might be useful to the website owners.", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_key_directive(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\#\s*Press\s*\d+\-\d+\s*\d+\-\d+\s*\+\s*\d+\-\d+\s*\d+\-\d+\s*\." + + inputLine = {"originalLine": "# Press {for mac}{key command}+{/for}{key Delete}.", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + def test_filepath_directive(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedSequence = "\#\s*Press\s*\d+\-\d+\s*\d+\-\d+\s*\+\s*\d+\-\d+\s*\." + + inputLine = {"originalLine": "# Press {for mac}{filepath mypath}+{/for}.", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.processMediaWikiLine(inputLine) + + currentPattern = re.compile(expectedSequence, re.IGNORECASE) + currentMatch = re.findall(currentPattern, inputLine["sequenceLine"]) + + assert len(currentMatch) == 1 + + diff --git a/test_wikitranslation.py b/test_wikitranslation.py new file mode 100644 index 0000000..9cdca35 --- /dev/null +++ b/test_wikitranslation.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import pytest +import unittest +import WikiParser +import re + +# +# Tests for the Google translation of various text sequences. +# +class TestWikiTranslation(unittest.TestCase): + + # + # Create the Device Under Test (DUT). + # + def setup_method(self, method): + pass + + # + # Perform any necessary clean-up. + # + def teardown_method(self, method): + pass + + ############## + # Test-Cases # + ############## + ##### Now lets test the translation of some simple lines ### + + def test_translate_Firefox_version(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedTranslatedLine = "Version de firefox" + + inputLine = {"originalLine": "Firefox version", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "Firefox version", + "sequences": [], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.translateMediaWikiLine(inputLine) + + assert expectedTranslatedLine.decode('utf8') == inputLine["translatedLine"] + + def test_translate_link_description(self): + + # Expected outputs. + expectedRawFilename = "orig_input" + expectedFilename = expectedRawFilename + ".txt" + expectedTranslatedLine = "[[Find what version of Firefox you are using | Versión de Firefox]]" + + inputLine = {"originalLine": "[[Find what version of Firefox you are using|Firefox version]]", + "translatedLine": "", + "lineNumber": 99, + "sequenceLine": "[[ 123.456 |Firefox version]]", + "sequences": [{"sequence": 123.456, + "original": "Find what version of Firefox you are using", + "translate": False}], + "emptyLine": False} + + # Build the Device Under Test. + self.dut = WikiParser.WikiParser(expectedFilename) + + self.dut.translateMediaWikiLine(inputLine) + + assert expectedTranslatedLine.decode('utf8') == inputLine["translatedLine"]