Skip to content

Commit

Permalink
Start i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesley Norton authored and Lesley Norton committed Sep 16, 2021
1 parent 50f5ebf commit 05dc48e
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 175 deletions.
256 changes: 256 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{
"openInNewTabTitle": {
"message": "Open New Tab in…",
"description": "Menu title"
},
"reopenThisSiteIn": {
"message": "Reopen This Site in…",
"description": "Menu title"
},
"sortTabsByContainer": {
"message": "Sort Tabs by Container",
"description": "Menu title"
},
"alwaysOpenThisSiteIn": {
"message": "Always Open This Site in…",
"description": "Menu title"
},
"alwaysOpenSiteInContainer": {
"message": "Always Open Site in Container"
},
"openNewTabInThisContainer": {
"message" : "Open New Tab in this Container"
},
"openTabs": {
"message": "Open Tabs"
},
"moveTabsToANewWindow": {
"message": "Move Tabs to a New Window"
},
"onboarding-1-header": {
"message": "A better way to manage all the things you do online"
},
"onboarding-1-description": {
"message": "Use containers to organize tasks, manage accounts, and keep your focus where you want it."
},
"onboarding-1-sec-header": {
"message": "A simple and secure way to manage your online life"
},
"onboarding-1-sec-description": {
"message" : "Use containers to organize tasks, manage accounts, and store sensitive data."
},
"onboarding-2-header": {
"message": "Put containers to work for you."
},
"onboarding-2-description": {
"message": "Features like color-coding and separate container tabs help you find things easily, focus your attention, and minimize distractions."
},
"onboarding-2-sec-description": {
"message": "Color-coding helps you categorize your online life, find things easily, and minimize distractions."
},
"onboarding-3-header": {
"message": "A place for everything, and everything in its place."
},
"onboarding-3-description": {
"message": "Start with the containers we've created, or create your own."
},
"onboarding-3-sec-header": {
"message": "Set boundaries for your browsing."
},
"onboarding-3-sec-description": {
"message": "Cookies are stored within a container, so you can segment sensitive data and browsing history to stay organized and to limit the impact of online trackers."
},
"onboarding-4-header": {
"message": "Always open sites in the containers you want."
},
"onboarding-4-description": {
"message": "Right-click inside a container tab to assign the site to always open in the container."
},
"onboarding-5-header": {
"message": "Container tabs when you need them."
},
"onboarding-5-description": {
"message": "Long-press the New Tab button to create a new container tab."
},
"onboarding-6-header": {
"message": "Syncing Containers is now Available!"
},
"onboarding-6-description": {
"message": "Turn on Sync to share container and site assignments with any computer connected to your Firefox Account."
},
"onboarding-7-header": {
"message": "Firefox Account is required to sync."
},
"onboarding-7-description": {
"message": "Click Sign In to confirm that your Firefox Account is active."
},
"oneHundredTabsHeader": {
"message": "100 tabs!"
},
"youHaveOpened": {
"message": "You've opened 100 Container tabs."
},
"spreadTheWord": {
"message": "If you enjoy Containers, help us spread the word!"
},
"rate": {
"message": "Rate"
},
"share": {
"message": "Share"
},
"tweet": {
"message": "Tweet"
},
"default": {
"message": "Default"
},
"manageContainers": {
"message": "Manage Containers"
},
"hideThisContainer": {
"message": "Hide This Container"
},
"removeThisContainer": {
"message": "Remove This Container"
},
"removeThisContainerConfirmation": {
"message": "Are you sure you want to remove this Container?"
},
"cancel": {
"message": "Cancel"
},
"ok": {
"message": "OK"
},
"sitesAssignedToThisContainer": {
"message": "Sites assigned to this container"
},
"options": {
"message": "Options"
},
"name": {
"message": "Name"
},
"color": {
"message": "Color"
},
"icon": {
"message": "Icon"
},
"limitToDesignatedSites": {
"message": "Limit to Designated Sites"
},
"deleteThisContainer": {
"message": "Delete This Container"
},
"manageSiteList": {
"message": "Manage Site List…"
},
"manageThisContainer": {
"message": "Manage This Container"
},
"containers": {
"message": "Containers"
},
"done": {
"message": "Done"
},
"getStarted": {
"message": "Get Started"
},
"signIn": {
"message": "Sign In"
},
"notNow": {
"message": "Not Now"
},
"startSyncing": {
"message": "Start Syncing"
},
"info": {
"message": "info"
},
"next": {
"message": "Next"
},
"openThisSiteConfirmation": {
"message": "Open this site in your assigned container?"
},
"wouldYouStillLikeToOpenConfirmation": {
"message": "Would you still like to open in this current container?"
},
"rememberMyDecision": {
"message": " Remember my decision for this site"
},
"optionalPermissions": {
"message": "Optional Permissions:"
},
"keyboardShortCuts": {
"message": "Keyboard Shortcuts:"
},
"onboarding": {
"message": "Onboarding"
},
"resetOnboardingPanels": {
"message": "Reset Onboarding Panels"
},
"onboardingToggle": {
"message": "Toggle this to see the onboarding panels again."
},
"tabBehavior": {
"message": "Tab behavior:"
},
"firefoxAccountsSync": {
"message": "Firefox Accounts Sync:"
},
"enableBookMarkMenus": {
"message": "Enable Bookmark Menus"
},
"enableSync": {
"message": "Enable Sync"
},
"enableBookMarkMenusDescription": {
"message": "This setting allows you to open a bookmark or folder of bookmarks in a container."
},
"enableSyncDescription": {
"message": "This setting allows you to sync your containers and site assignments across devices."
},
"replaceTab": {
"message": "This setting allows you to sync your containers and site assignments across devices."
},
"replaceTabDescription": {
"message": "Replace the current tab if a page which is assigned to another container is opened (instead of keeping the current tab open). Opening tabs with middle mouse button is not affected."
},
"editWhichContainer": {
"message": "Edit which container is opened when using the numbered shortcuts."
},
"keyboardShortCut": {
"message": "Container to open with Keyboard Shortcut $keyId$",
"placeholders": {
"keyId": {
"content": "$1"
}
}
},
"confirmNavigationTitle": {
"message": "Multi-Account Containers Confirm Navigation",
"description": "This is the title of a confirmation page. Please do not translate \"Multi-Account Containers\"."
},
"openInContainer": {
"message": "Open in $containerName$ Container",
"placeholders": {
"containerName": {
"content": "$1"
}
}
},
"youAskedFirefox": {
"message": "You asked Firefox to always open $containerName$ for this site:",
"placeholders": {
"containerName": {
"content": "$1"
}
}
}
}
17 changes: 8 additions & 9 deletions src/confirm-page.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Multi-Account Containers Confirm Navigation</title>
<title data-i18n-message-id="confirmNavigationTitle"></title>
<link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" href="chrome://browser/skin/aboutNetError.css" type="text/css" media="all" />
<script type="text/javascript" src="./js/i18n.js"></script>
<link rel="stylesheet" href="/css/confirm-page.css" />
</head>
<body>
<main>
<div class="title">
<h1 class="title-text">Open this site in your assigned container?</h1>
<h1 class="title-text" data-i18n-message-id="openThisSiteConfirmation"></h1>
</div>
<form id="redirect-form">
<p>
You asked <dfn id="browser-name" title="Thanks for trying out Containers. Sorry we may have got your browser name wrong. #FxNightly" >Firefox</dfn> to always open <dfn class="container-name"></dfn> for this site:<br />
</p>
<p data-message-id="youAskedFireFox" data-message-arg="container-name"></p>
<div id="redirect-url"></div>
<p>Would you still like to open in this current container?</p>
<p data-i18n-message-id="wouldYouStillLikeToOpenConfirmation"></p>
<br />
<br />
<label for="never-ask" class="check-label">
<input id="never-ask" type="checkbox" />
Remember my decision for this site
<span data-i18n-message-id="rememberMyDecision"></span>
</label>
<br />
<div class="button-container">
<button id="deny" class="button">Open in <dfn id="current-container-name">Current</dfn> Container</button>
<button id="confirm" class="button primary" autofocus>Open in <dfn class="container-name"></dfn> Container</button>
<button id="deny" class="button" data-message-id="openInContainer" data-message-arg="current-container-name"></button>
<button id="confirm" class="button primary" data-message-id="openInContainer" data-message-arg="container-name"></button>
</div>
</form>
</main>
Expand Down
20 changes: 10 additions & 10 deletions src/js/confirm-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ async function load() {
redirectUrlElement.textContent = redirectUrl;
appendFavicon(redirectUrl, redirectUrlElement);

const container = await browser.contextualIdentities.get(cookieStoreId);
[...document.querySelectorAll(".container-name")].forEach((containerNameElement) => {
containerNameElement.textContent = container.name;
});

// If default container, button will default to normal HTML content
if (currentCookieStoreId) {
const currentContainer = await browser.contextualIdentities.get(currentCookieStoreId);
document.getElementById("current-container-name").textContent = currentContainer.name;
}
document.getElementById("deny").addEventListener("click", (e) => {
e.preventDefault();
denySubmit(redirectUrl);
});

const container = await browser.contextualIdentities.get(cookieStoreId);
const currentContainer = currentCookieStoreId ? await browser.contextualIdentities.get(currentCookieStoreId) : null;
const currentContainerName = currentContainer ? currentContainer.name : ""

document.querySelectorAll("[data-message-id]").forEach(el => {
const elementData = el.dataset;
const containerName = elementData.messageArg === "container-name" ? container.name : currentContainerName;
el.textContent = browser.i18n.getMessage(elementData.messageId, containerName);
});

document.getElementById("confirm").addEventListener("click", (e) => {
e.preventDefault();
confirmSubmit(redirectUrl, cookieStoreId);
Expand Down
9 changes: 9 additions & 0 deletions src/js/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener("DOMContentLoaded", async () => {
document.querySelectorAll("[data-i18n-message-id]").forEach(el => {
const messageArgs = el.dataset.i18nPlaceholder ? el.dataset.i18nPlaceholder : null;
el.textContent = browser.i18n.getMessage(el.dataset.i18nMessageId, [messageArgs]);
});
document.querySelectorAll("[data-i18n-attribute]").forEach(el => {
el.setAttribute(el.dataset.i18nAttribute, browser.i18n.getMessage(el.dataset.i18nAttributeMessageId));
});
});
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"run_at": "document_start"
}
],
"default_locale": "en",
"web_accessible_resources": [
"/img/container-site-d-24.png"
],
Expand Down

0 comments on commit 05dc48e

Please sign in to comment.