From 78ba479a35260ffdcaf724168802e40ecfa7aae8 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Mon, 14 Sep 2020 15:57:46 -0700 Subject: Fix check_lacked_trans.py so it works with black formatting, and remove unused translations from en.json --- install/check_lacked_trans.py | 65 +++++++++++++++++++++++++++++++------------ share/locale/en.json | 47 +------------------------------ 2 files changed, 48 insertions(+), 64 deletions(-) diff --git a/install/check_lacked_trans.py b/install/check_lacked_trans.py index 62986707..965b103b 100755 --- a/install/check_lacked_trans.py +++ b/install/check_lacked_trans.py @@ -27,7 +27,12 @@ es disused gui_starting_server """ -import fileinput, argparse, re, os, codecs, json, sys +import argparse +import re +import os +import codecs +import json +import sys def arg_parser(): @@ -68,29 +73,53 @@ def main(): dir = args.onionshare_dir src = ( - files_in(dir, "onionshare") - + files_in(dir, "onionshare_gui") - + files_in(dir, "onionshare_gui/mode") - + files_in(dir, "onionshare_gui/mode/share_mode") - + files_in(dir, "onionshare_gui/mode/receive_mode") - + files_in(dir, "onionshare_gui/mode/website_mode") + files_in(dir, "onionshare_gui") + + files_in(dir, "onionshare_gui/tab") + + files_in(dir, "onionshare_gui/tab/mode") + + files_in(dir, "onionshare_gui/tab/mode/chat_mode") + + files_in(dir, "onionshare_gui/tab/mode/receive_mode") + + files_in(dir, "onionshare_gui/tab/mode/share_mode") + + files_in(dir, "onionshare_gui/tab/mode/website_mode") + files_in(dir, "install/scripts") - + files_in(dir, "tests") ) - pysrc = [p for p in src if p.endswith(".py")] + filenames = [p for p in src if p.endswith(".py")] lang_code = args.lang_code translate_keys = set() - # load translate key from python source - for line in fileinput.input(pysrc, openhook=fileinput.hook_encoded("utf-8")): - # search `strings._('translate_key')` - # `strings._('translate_key', True)` - m = re.findall(r"strings\._\((.*?)\)", line) - if m: - for match in m: - key = match.split(",")[0].strip(""""' """) - translate_keys.add(key) + for filename in filenames: + # load translate key from python source + with open(filename) as f: + src = f.read() + + # find all the starting strings + start_substr = "strings._\(" + starting_indices = [m.start() for m in re.finditer(start_substr, src)] + + for starting_i in starting_indices: + # are we dealing with single quotes or double quotes? + quote = None + inc = 0 + while True: + quote_i = starting_i + len("strings._(") + inc + if src[quote_i] == '"': + quote = '"' + break + elif src[quote_i] == "'": + quote = "'" + break + else: + inc += 1 + + # find the starting quote + starting_i = src.find(quote, starting_i) + if starting_i: + starting_i += 1 + # find the ending quote + ending_i = src.find(quote, starting_i) + if ending_i: + key = src[starting_i:ending_i] + translate_keys.add(key) if args.show_all_keys: for k in sorted(translate_keys): diff --git a/share/locale/en.json b/share/locale/en.json index bb11cdfd..26d874de 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -1,7 +1,5 @@ { - "preparing_files": "Compressing files.", "not_a_readable_file": "{0:s} is not a readable file.", - "no_available_port": "Could not find an available port to start the onion service", "other_page_loaded": "Address loaded", "incorrect_password": "Incorrect password", "close_on_autostop_timer": "Stopped because auto-stop timer ran out", @@ -17,7 +15,6 @@ "gui_share_start_server": "Start sharing", "gui_share_stop_server": "Stop sharing", "gui_share_stop_server_autostop_timer": "Stop Sharing ({})", - "gui_chat_stop_server_autostop_timer": "Stop Chat Server ({})", "gui_chat_start_server": "Start chat server", "gui_chat_stop_server": "Stop chat server", "gui_stop_server_autostop_timer_tooltip": "Auto-stop timer ends at {}", @@ -40,23 +37,12 @@ "gui_please_wait": "Starting… Click to cancel.", "error_rate_limit": "Someone has made too many wrong attempts to guess your password, so OnionShare has stopped the server. Start sharing again and send the recipient a new address to share.", "zip_progress_bar_format": "Compressing: %p%", - "error_stealth_not_supported": "To use client authorization, you need at least both Tor 0.2.9.1-alpha (or Tor Browser 6.5) and python3-stem 1.5.0.", - "error_ephemeral_not_supported": "OnionShare requires at least both Tor 0.2.7.1 and python3-stem 1.4.0.", "gui_settings_window_title": "Settings", - "gui_settings_whats_this": "What's this?", - "gui_settings_stealth_option": "Use client authorization", - "gui_settings_stealth_hidservauth_string": "Having saved your private key for reuse, means you can now click to copy your HidServAuth.", "gui_settings_autoupdate_label": "Check for new version", "gui_settings_autoupdate_option": "Notify me when a new version is available", "gui_settings_autoupdate_timestamp": "Last checked: {}", "gui_settings_autoupdate_timestamp_never": "Never", "gui_settings_autoupdate_check_button": "Check for New Version", - "gui_settings_general_label": "General settings", - "gui_settings_onion_label": "Onion settings", - "gui_settings_sharing_label": "Sharing settings", - "gui_settings_close_after_first_download_option": "Stop sharing after files have been sent", - "gui_settings_csp_header_disabled_option": "Disable Content Security Policy header", - "gui_settings_individual_downloads_label": "Uncheck to allow downloading individual files", "gui_settings_connection_type_label": "How should OnionShare connect to Tor?", "gui_settings_connection_type_bundled_option": "Use the Tor version built into OnionShare", "gui_settings_connection_type_automatic_option": "Attempt auto-configuration with Tor Browser", @@ -83,23 +69,7 @@ "gui_settings_button_save": "Save", "gui_settings_button_cancel": "Cancel", "gui_settings_button_help": "Help", - "gui_settings_autostop_timer_checkbox": "Use auto-stop timer", - "gui_settings_autostop_timer": "Stop the share at:", - "gui_settings_autostart_timer_checkbox": "Use auto-start timer", - "gui_settings_autostart_timer": "Start the share at:", - "settings_error_unknown": "Can't connect to Tor controller because your settings don't make sense.", - "settings_error_automatic": "Could not connect to the Tor controller. Is Tor Browser (available from torproject.org) running in the background?", - "settings_error_socket_port": "Can't connect to the Tor controller at {}:{}.", - "settings_error_socket_file": "Can't connect to the Tor controller using socket file {}.", - "settings_error_auth": "Connected to {}:{}, but can't authenticate. Maybe this isn't a Tor controller?", - "settings_error_missing_password": "Connected to Tor controller, but it requires a password to authenticate.", - "settings_error_unreadable_cookie_file": "Connected to the Tor controller, but password may be wrong, or your user is not permitted to read the cookie file.", - "settings_error_bundled_tor_not_supported": "Using the Tor version that comes with OnionShare does not work in developer mode on Windows or macOS.", - "settings_error_bundled_tor_timeout": "Taking too long to connect to Tor. Maybe you aren't connected to the Internet, or have an inaccurate system clock?", - "settings_error_bundled_tor_broken": "OnionShare could not connect to Tor:\n{}", "settings_test_success": "Connected to the Tor controller.\n\nTor version: {}\nSupports ephemeral onion services: {}.\nSupports client authentication: {}.\nSupports next-gen .onion addresses: {}.", - "error_tor_protocol_error": "There was an error with Tor: {}", - "error_tor_protocol_error_unknown": "There was an unknown error with Tor", "connecting_to_tor": "Connecting to the Tor network", "update_available": "New OnionShare out. Click here to get it.

You are using {} and the latest is {}.", "update_error_invalid_latest_version": "Could not check for new version: The OnionShare website is saying the latest version is the unrecognizable '{}'…", @@ -116,9 +86,6 @@ "gui_server_autostart_timer_expired": "The scheduled time has already passed. Please adjust it to start sharing.", "gui_autostop_timer_cant_be_earlier_than_autostart_timer": "The auto-stop time can't be the same or earlier than the auto-start time. Please adjust it to start sharing.", "share_via_onionshare": "Share via OnionShare", - "gui_connect_to_tor_for_onion_settings": "Connect to Tor to see onion service settings", - "gui_use_legacy_v2_onions_checkbox": "Use legacy addresses", - "gui_save_private_key_checkbox": "Use a persistent address", "gui_share_url_description": "Anyone with this OnionShare address can download your files using the Tor Browser: ", "gui_website_url_description": "Anyone with this OnionShare address can visit your website using the Tor Browser: ", "gui_receive_url_description": "Anyone with this OnionShare address can upload files to your computer using the Tor Browser: ", @@ -141,14 +108,6 @@ "history_requests_tooltip": "{} web requests", "error_cannot_create_data_dir": "Could not create OnionShare data folder: {}", "gui_receive_mode_warning": "Receive mode lets people upload files to your computer.

Some files can potentially take control of your computer if you open them. Only open things from people you trust, or if you know what you are doing.", - "gui_mode_share_button": "Share Files", - "gui_mode_receive_button": "Receive Files", - "gui_mode_website_button": "Publish Website", - "gui_settings_receiving_label": "Receiving settings", - "gui_settings_website_label": "Website settings", - "gui_settings_data_dir_label": "Save files to", - "gui_settings_data_dir_browse_button": "Browse", - "gui_settings_public_mode_checkbox": "Public mode", "gui_open_folder_error": "Failed to open folder with xdg-open. The file is here: {}", "gui_settings_language_label": "Preferred language", "gui_settings_language_changed_notice": "Restart OnionShare for the new language to be applied.", @@ -166,10 +125,6 @@ "gui_all_modes_history": "History", "gui_all_modes_clear_history": "Clear All", "gui_all_modes_transfer_started": "Started {}", - "gui_all_modes_transfer_finished_range": "Transferred {} - {}", - "gui_all_modes_transfer_finished": "Transferred {}", - "gui_all_modes_transfer_canceled_range": "Canceled {} - {}", - "gui_all_modes_transfer_canceled": "Canceled {}", "gui_all_modes_progress_complete": "%p%, {0:s} elapsed.", "gui_all_modes_progress_starting": "{0:s}, %p% (calculating)", "gui_all_modes_progress_eta": "{0:s}, ETA: {1:s}, %p%", @@ -219,4 +174,4 @@ "mode_settings_receive_data_dir_label": "Save files to", "mode_settings_receive_data_dir_browse_button": "Browse", "mode_settings_website_disable_csp_checkbox": "Don't send Content Security Policy header (allows your website to use third-party resources)" -} +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf