Skip to content
Snippets Groups Projects
Commit 990817ec authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

Add TorStrings module for localization

parent fa088a44
No related branches found
No related tags found
1 merge request!1503TB 43415, part 3: Shuffle commits
......@@ -231,6 +231,10 @@
; Base Browser
@RESPATH@/components/SecurityLevel.manifest
; Tor Browser localization files
@RESPATH@/chrome/torbutton.manifest
@RESPATH@/chrome/torbutton/*
; [DevTools Startup Files]
@RESPATH@/browser/chrome/devtools-startup@JAREXT@
@RESPATH@/browser/chrome/devtools-startup.manifest
......
......
......@@ -131,6 +131,10 @@
; Base Browser
@BINPATH@/components/SecurityLevel.manifest
; Torbutton
@BINPATH@/chrome/torbutton@JAREXT@
@BINPATH@/chrome/torbutton.manifest
; [Default Preferences]
; All the pref files must be part of base to prevent migration bugs
#ifndef MOZ_ANDROID_FAT_AAR_ARCHITECTURES
......
......
// Copyright (c) 2022, The Tor Project, Inc.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
function getLocale() {
const locale = Services.locale.appLocaleAsBCP47;
return locale === "ja-JP-macos" ? "ja" : locale;
}
/*
Tor Property String Bundle
Property strings loaded from torbutton/tor-launcher, but provide a fallback in case they aren't available
*/
class TorPropertyStringBundle {
constructor(aBundleURL, aPrefix) {
try {
this._bundle = Services.strings.createBundle(aBundleURL);
this._bundleURL = aBundleURL;
} catch (e) {
console.error(`[TorStrings] Cannot load ${aBundleURL}`, e);
}
this._prefix = aPrefix;
}
getString(key, fallback) {
const reportError =
AppConstants.BASE_BROWSER_VERSION === "dev-build" && !!this._bundle;
if (key) {
try {
return this._bundle.GetStringFromName(`${this._prefix}${key}`);
} catch (e) {
if (reportError) {
console.warn(
`[TorStrings] Cannot get ${this._prefix}${key} from ${this._bundleURL}`,
e
);
}
}
}
// on failure, assign the fallback if it exists
if (fallback) {
return fallback;
}
// otherwise return string key
return `$(${key})`;
}
getStrings(strings, additionalPrefix = "") {
return Object.fromEntries(
Object.entries(strings).map(([key, fallback]) => [
key,
this.getString(additionalPrefix + key, fallback),
])
);
}
}
const Loader = {
/*
Tor about:preferences#connection Strings
*/
settings() {
const strings = {
// Message box
torPreferencesDescription:
"Tor Browser routes your traffic over the Tor network, run by thousands of volunteers around the world.",
// Quickstart
quickstartCheckbox: "Always connect automatically",
bridgeLocation: "Your location",
bridgeLocationAutomatic: "Automatic",
bridgeLocationFrequent: "Frequently selected locations",
bridgeLocationOther: "Other locations",
bridgeChooseForMe: "Choose a Bridge For Me…",
};
const tsb = new TorPropertyStringBundle(
"chrome://torbutton/locale/settings.properties",
"settings."
);
return tsb.getStrings(strings);
} /* Tor Network Settings Strings */,
torConnect() {
const strings = {
torConnect: "Connect to Tor",
torConnecting: "Establishing a Connection",
tryingAgain: "Trying again…",
noInternet: "Tor Browser couldn’t reach the Internet",
noInternetDescription:
"This could be due to a connection issue rather than Tor being blocked. Check your Internet connection, proxy and firewall settings before trying again.",
torBootstrapFailed: "Tor failed to establish a Tor network connection.",
couldNotConnect: "Tor Browser could not connect to Tor",
configureConnection: "configure your connection",
assistDescription:
"If Tor is blocked in your location, trying a bridge may help. Connection assist can choose one for you using your location, or you can %S manually instead.",
tryingBridge: "Trying a bridge…",
tryingBridgeAgain: "Trying one more time…",
errorLocation: "Tor Browser couldn’t locate you",
errorLocationDescription:
"Tor Browser needs to know your location in order to choose the right bridge for you. If you’d rather not share your location, %S manually instead.",
isLocationCorrect: "Are these location settings correct?",
isLocationCorrectDescription:
"Tor Browser still couldn’t connect to Tor. Please check your location settings are correct and try again, or %S instead.",
finalError: "Tor Browser still cannot connect",
finalErrorDescription:
"Despite its best efforts, connection assist was not able to connect to Tor. Try troubleshooting your connection and adding a bridge manually instead.",
breadcrumbAssist: "Connection assist",
breadcrumbLocation: "Location settings",
breadcrumbTryBridge: "Try a bridge",
restartTorBrowser: "Restart Tor Browser",
torConfigure: "Configure Connection…",
viewLog: "View logs…",
torConnectButton: "Connect",
cancel: "Cancel",
torConnected: "Connected to the Tor network",
tryAgain: "Try Again",
yourLocation: "Your Location",
unblockInternetIn: "Unblock the Internet in",
tryBridge: "Try a Bridge",
automatic: "Automatic",
selectCountryRegion: "Select Country or Region",
frequentLocations: "Frequently selected locations",
otherLocations: "Other locations",
// TorConnect error messages
offline: "Internet not reachable",
autoBootstrappingFailed: "Automatic configuration failed",
autoBootstrappingAllFailed: "None of the configurations we tried worked",
cannotDetermineCountry: "Unable to determine user country",
noSettingsForCountry: "No settings available for your location",
// Titlebar status.
titlebarStatusName: "Tor connection",
titlebarStatusNotConnected: "Not connected",
titlebarStatusConnecting: "Connecting…",
titlebarStatusPotentiallyBlocked: "Potentially blocked",
titlebarStatusConnected: "Connected",
};
// Some strings were used through TorLauncherUtils.
// However, we need to use them in about:torconnect, which cannot access
// privileged code.
const bootstrapStatus = {
starting: "Starting",
conn_pt: "Connecting to bridge",
conn_done_pt: "Connected to bridge",
conn_proxy: "Connecting to proxy",
conn_done_proxy: "Connected to proxy",
conn: "Connecting to a Tor relay",
conn_done: "Connected to a Tor relay",
handshake: "Negotiating with a Tor relay",
handshake_done: "Finished negotiating with a Tor relay",
onehop_create: "Establishing an encrypted directory connection",
requesting_status: "Retrieving network status",
loading_status: "Loading network status",
loading_keys: "Loading authority certificates",
requesting_descriptors: "Requesting relay information",
loading_descriptors: "Loading relay information",
enough_dirinfo: "Finished loading relay information",
ap_conn_pt: "Building circuits: Connecting to bridge",
ap_conn_done_pt: "Building circuits: Connected to bridge",
ap_conn_proxy: "Building circuits: Connecting to proxy",
ap_conn_done_proxy: "Building circuits: Connected to proxy",
ap_conn: "Building circuits: Connecting to a Tor relay",
ap_conn_done: "Building circuits: Connected to a Tor relay",
ap_handshake: "Building circuits: Negotiating with a Tor relay",
ap_handshake_done:
"Building circuits: Finished negotiating with a Tor relay",
circuit_create: "Building circuits: Establishing a Tor circuit",
done: "Connected to the Tor network!",
};
const bootstrapWarning = {
done: "done",
connectrefused: "connection refused",
misc: "miscellaneous",
resourcelimit: "insufficient resources",
identity: "identity mismatch",
timeout: "connection timeout",
noroute: "no route to host",
ioerror: "read/write error",
pt_missing: "missing pluggable transport",
};
const tsb = new TorPropertyStringBundle(
"chrome://torbutton/locale/torConnect.properties",
"torConnect."
);
const tlsb = new TorPropertyStringBundle(
"chrome://torbutton/locale/torlauncher.properties",
"torlauncher."
);
return {
...tsb.getStrings(strings),
bootstrapFailedDetails: tlsb.getString(
"tor_bootstrap_failed_details",
"%1$S failed (%2$S)."
),
bootstrapStatus: tlsb.getStrings(bootstrapStatus, "bootstrapStatus."),
bootstrapWarning: tlsb.getStrings(bootstrapWarning, "bootstrapWarning."),
};
},
/*
OnionLocation
*/
onionLocation() {
const strings = {
learnMore: "Learn more…",
loadOnion: "Visit the .onion",
loadOnionAccessKey: "V",
notNow: "Not Now",
notNowAccessKey: "n",
description:
"There's a more private and secure version of this site available over the Tor network via onion services. Onion services help website publishers and their visitors defeat surveillance and censorship.",
tryThis: "Try Onion Services",
onionAvailable: ".onion available",
};
const tsb = new TorPropertyStringBundle(
["chrome://torbutton/locale/onionLocation.properties"],
"onionLocation."
);
return {
...tsb.getStrings(strings),
learnMoreURL: "about:manual#onion-services",
// XUL popups cannot open about: URLs, but we are online when showing the notification, so just use the online version
learnMoreURLNotification: `https://tb-manual.torproject.org/${getLocale()}/onion-services/`,
};
} /* OnionLocation */,
};
export const TorStrings = {
get settings() {
if (!this._settings) {
this._settings = Loader.settings();
}
return this._settings;
},
get torConnect() {
if (!this._torConnect) {
this._torConnect = Loader.torConnect();
}
return this._torConnect;
},
get onionLocation() {
if (!this._onionLocation) {
this._onionLocation = Loader.onionLocation();
}
return this._onionLocation;
},
};
......@@ -209,6 +209,7 @@ EXTRA_JS_MODULES += [
"Sqlite.sys.mjs",
"SubDialog.sys.mjs",
"Timer.sys.mjs",
"TorStrings.sys.mjs",
"Troubleshoot.sys.mjs",
"UpdateUtils.sys.mjs",
"WebChannel.sys.mjs",
......
......
......@@ -22,6 +22,7 @@ DIRS += [
"mozapps/preferences",
"profile",
"themes",
"torbutton",
]
if CONFIG["OS_ARCH"] == "WINNT":
......
......
# Copyright (c) 2022, The Tor Project, Inc.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Onion-Location strings.
onionLocation.loadOnion=Visit the .onion
# Localization note: this is the access key for "Visit the .onion".
# It should be a character that appears in that string.
onionLocation.loadOnionAccessKey=V
onionLocation.notNow=Not Now
# Localization note: this is the access key for "Not now".
# It should be a character that appears in that string.
onionLocation.notNowAccessKey=n
onionLocation.description=There's a more private and secure version of this site available over the Tor network via onion services. Onion services help website publishers and their visitors defeat surveillance and censorship.
onionLocation.tryThis=Try Onion Services
onionLocation.onionAvailable=.onion available
onionLocation.learnMore=Learn more…
# Copyright (c) 2022, The Tor Project, Inc.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Still used in TorConnect.
# Message box
settings.torPreferencesDescription=Tor Browser routes your traffic over the Tor network, run by thousands of volunteers around the world.
settings.quickstartCheckbox=Always connect automatically
# Might be removed in tor-browser#42477
settings.bridgeLocation=Your location
settings.bridgeLocationAutomatic=Automatic
settings.bridgeLocationFrequent=Frequently selected locations
settings.bridgeLocationOther=Other locations
settings.bridgeChooseForMe=Choose a Bridge For Me…
# Copyright (c) 2022, The Tor Project, Inc.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
torConnect.titlebarStatusName=Tor connection
torConnect.titlebarStatusNotConnected=Not connected
torConnect.titlebarStatusConnecting=Connecting…
torConnect.titlebarStatusPotentiallyBlocked=Potentially blocked
torConnect.titlebarStatusConnected=Connected
torConnect.torConnect=Connect to Tor
torConnect.torConnecting=Establishing a Connection
torConnect.tryingAgain=Trying again…
torConnect.noInternet=Tor Browser couldn’t reach the Internet
torConnect.noInternetDescription=This could be due to a connection issue rather than Tor being blocked. Check your Internet connection, proxy and firewall settings before trying again.
torConnect.torBootstrapFailed=Tor failed to establish a Tor network connection.
torConnect.couldNotConnect=Tor Browser could not connect to Tor
# Translation note: used as a text to insert as a link on several strings (%S)
torConnect.configureConnection=configure your connection
# Translation note: %S = "configure your connection" link
torConnect.assistDescription=If Tor is blocked in your location, trying a bridge may help. Connection assist can choose one for you using your location, or you can %S manually instead.
torConnect.tryingBridge=Trying a bridge…
torConnect.tryingBridgeAgain=Trying one more time…
torConnect.errorLocation=Tor Browser couldn’t locate you
# Translation note: %S = "configure your connection" link
torConnect.errorLocationDescription=Tor Browser needs to know your location in order to choose the right bridge for you. If you’d rather not share your location, %S manually instead.
torConnect.isLocationCorrect=Are these location settings correct?
# Translation note: %S = "configure your connection" link
torConnect.isLocationCorrectDescription=Tor Browser still couldn’t connect to Tor. Please check your location settings are correct and try again, or %S instead.
torConnect.finalError=Tor Browser still cannot connect
torConnect.finalErrorDescription=Despite its best efforts, connection assist was not able to connect to Tor. Try troubleshooting your connection and adding a bridge manually instead.
torConnect.breadcrumbAssist=Connection assist
torConnect.breadcrumbLocation=Location settings
torConnect.breadcrumbTryBridge=Try a bridge
torConnect.restartTorBrowser=Restart Tor Browser
torConnect.torConfigure=Configure Connection…
torConnect.viewLog=View logs…
torConnect.torConnectButton=Connect
torConnect.cancel=Cancel
torConnect.torConnected=Connected to the Tor network!
torConnect.tryAgain=Try Again
torConnect.yourLocation=Your Location
torConnect.unblockInternetIn=Unblock the Internet in
torConnect.tryBridge=Try a Bridge
torConnect.automatic=Automatic
torConnect.selectCountryRegion=Select Country or Region
torConnect.frequentLocations=Frequently selected locations
torConnect.otherLocations=Other locations
torConnect.offline=Internet not reachable
torConnect.autoBootstrappingFailed=Automatic configuration failed
torConnect.autoBootstrappingAllFailed=None of the configurations we tried worked
torConnect.cannotDetermineCountry=Unable to determine user country
torConnect.noSettingsForCountry=No settings available for your location
# Copyright (c) 2022, The Tor Project, Inc.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
torlauncher.error_title=Tor Launcher
torlauncher.tor_exited_during_startup=Tor exited during startup. This might be due to an error in your torrc file, a bug in Tor or another program on your system, or faulty hardware. Until you fix the underlying problem and restart Tor, Tor Browser will not start.
torlauncher.tor_exited=Tor unexpectedly exited. This might be due to a bug in Tor itself, another program on your system, or faulty hardware. Until you restart Tor, Tor Browser will not be able to reach any websites. If the problem persists, please send a copy of your Tor Log to the support team.
torlauncher.tor_exited2=Restarting Tor will not close your browser tabs.
torlauncher.restart_tor=Restart Tor
# Translation note: %1$S is a bootstrap phase from torlauncher.bootstrapStatus,
# %2$S is the error from torlauncher.bootstrapWarning
torlauncher.tor_bootstrap_failed_details=%1$S failed (%2$S).
torlauncher.bootstrapStatus.starting=Starting
torlauncher.bootstrapStatus.conn_pt=Connecting to bridge
torlauncher.bootstrapStatus.conn_done_pt=Connected to bridge
torlauncher.bootstrapStatus.conn_proxy=Connecting to proxy
torlauncher.bootstrapStatus.conn_done_proxy=Connected to proxy
torlauncher.bootstrapStatus.conn=Connecting to a Tor relay
torlauncher.bootstrapStatus.conn_done=Connected to a Tor relay
torlauncher.bootstrapStatus.handshake=Negotiating with a Tor relay
torlauncher.bootstrapStatus.handshake_done=Finished negotiating with a Tor relay
torlauncher.bootstrapStatus.onehop_create=Establishing an encrypted directory connection
torlauncher.bootstrapStatus.requesting_status=Retrieving network status
torlauncher.bootstrapStatus.loading_status=Loading network status
torlauncher.bootstrapStatus.loading_keys=Loading authority certificates
torlauncher.bootstrapStatus.requesting_descriptors=Requesting relay information
torlauncher.bootstrapStatus.loading_descriptors=Loading relay information
torlauncher.bootstrapStatus.enough_dirinfo=Finished loading relay information
torlauncher.bootstrapStatus.ap_conn_pt=Building circuits: Connecting to bridge
torlauncher.bootstrapStatus.ap_conn_done_pt=Building circuits: Connected to bridge
torlauncher.bootstrapStatus.ap_conn_proxy=Building circuits: Connecting to proxy
torlauncher.bootstrapStatus.ap_conn_done_proxy=Building circuits: Connected to proxy
torlauncher.bootstrapStatus.ap_conn=Building circuits: Connecting to a Tor relay
torlauncher.bootstrapStatus.ap_conn_done=Building circuits: Connected to a Tor relay
torlauncher.bootstrapStatus.ap_handshake=Building circuits: Negotiating with a Tor relay
torlauncher.bootstrapStatus.ap_handshake_done=Building circuits: Finished negotiating with a Tor relay
torlauncher.bootstrapStatus.circuit_create=Building circuits: Establishing a Tor circuit
torlauncher.bootstrapStatus.done=Connected to the Tor network!
torlauncher.bootstrapWarning.done=done
torlauncher.bootstrapWarning.connectrefused=connection refused
torlauncher.bootstrapWarning.misc=miscellaneous
torlauncher.bootstrapWarning.resourcelimit=insufficient resources
torlauncher.bootstrapWarning.identity=identity mismatch
torlauncher.bootstrapWarning.timeout=connection timeout
torlauncher.bootstrapWarning.noroute=no route to host
torlauncher.bootstrapWarning.ioerror=read/write error
torlauncher.bootstrapWarning.pt_missing=missing pluggable transport
#filter substitution
torbutton.jar:
% resource torbutton %
% category l10n-registry torbutton resource://torbutton/locale/{locale}/
% locale torbutton en-US %locale/en-US/
locale/en-US/ (chrome/locale/en-US/*)
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
JAR_MANIFESTS += ["jar.mn"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment