mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-21 17:49:56 +01:00
#1254 Loco import/export scripts
This commit is contained in:
parent
5dd1f4671a
commit
a47fe63261
@ -1,2 +1,3 @@
|
||||
API_URL=
|
||||
WS_URL=
|
||||
LOCO_KEY=
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -116,4 +116,5 @@ fastlane/test_output
|
||||
# https://github.com/johnno1962/injectionforxcode
|
||||
|
||||
iOSInjectionProject/
|
||||
.xcuserstate
|
||||
.xcuserstate
|
||||
utils/export/messages.json
|
@ -24,6 +24,8 @@
|
||||
"safari-prod": "yarn clean && yarn generate-locales && npx browserslist@latest --update-db && cross-env EXT_PLATFORM=Safari NODE_ENV=production node_modules/.bin/webpack --mode production --progress --config webpack/production.config.js",
|
||||
"all-build": "rimraf --glob ./build/* && yarn generate-license-info && yarn chrome-build && yarn opera-build && yarn firefox-build && yarn edge-build",
|
||||
"browserlist-update": "npx browserslist@latest --update-db",
|
||||
"loco-export": "node webpack/utils/locoExport.js",
|
||||
"loco-import": "node webpack/utils/locoImport.js",
|
||||
"generate-locales": "node webpack/utils/generateLocales.js",
|
||||
"generate-license-info-html": "license-report --output=html >> open-source-licenses.html",
|
||||
"generate-license-info-json": "license-report --output=json >> open-source-licenses.json",
|
||||
@ -66,6 +68,7 @@
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"css-loader": "^6.8.1",
|
||||
"css-minimizer-webpack-plugin": "^5.0.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"dotenv-webpack": "^8.0.1",
|
||||
"eslint": "8.49.0",
|
||||
"eslint-config-standard": "^17.1.0",
|
||||
|
0
webpack/utils/export/.gitkeep
Normal file
0
webpack/utils/export/.gitkeep
Normal file
156
webpack/utils/export/messages.json
Normal file
156
webpack/utils/export/messages.json
Normal file
@ -0,0 +1,156 @@
|
||||
{
|
||||
"2fasSupport": "2FAS Support",
|
||||
"2fasLogo": "2FAS Logo",
|
||||
"2fasAuthApp": "2FAS Auth App",
|
||||
"2fasAuthGP": "2FAS Auth on Google Play",
|
||||
"2fasAuthAP": "2FAS Auth on App Store",
|
||||
"unknown": "Unknown",
|
||||
"unknownOS": "Unknown OS",
|
||||
"browserOnOs": "on",
|
||||
"close": "Close",
|
||||
"set": "Set",
|
||||
"edit": "Edit",
|
||||
"info": "Info",
|
||||
"next": "Next",
|
||||
"previous": "Previous",
|
||||
"save": "Save",
|
||||
"version": "Version",
|
||||
"yes": "Yes",
|
||||
"cancel": "Cancel",
|
||||
"shortcut": "Shortcut",
|
||||
"neverShowAgain": "Never show again",
|
||||
"isNotSupportedByExt": "is not supported by 2FAS Extension",
|
||||
"shortcutSetDesc": "Set a shortcut to open the 2FAS Browser Extension on any page.",
|
||||
"shortcutUseDesc": "Use this shortcut to open the 2FAS Browser Extension on any page.",
|
||||
"pushNotifications": "Push notifications",
|
||||
"learnMore": "Learn more",
|
||||
"advanced": "Advanced",
|
||||
"playVideo": "Play video",
|
||||
"extNicknameHeader": "Extension's nickname",
|
||||
"extNicknameDesc": "Update the nickname for the 2FAS Browser Extension that will be visible on your mobile device. You can also change it later in the extension settings.",
|
||||
"extNicknameLabel": "This browser’s nickname:",
|
||||
"extNicknamePlaceholder": "Enter extension name...",
|
||||
"openTutorial": "Open tutorial",
|
||||
"download": "Download",
|
||||
"qrCode": "QR Code",
|
||||
"modalDisconnectDeviceHeader": "Disconnect device",
|
||||
"modalDisconnectDeviceText": "You are attempting to disconnect the device \"DEVICE_NAME\" from this browser extension. Are you sure?",
|
||||
"modalSafariResetHeader": "Browser Extension reset",
|
||||
"modalSafariResetText": "You are attempting to reset the 2FAS Browser Extension. Are you sure?",
|
||||
"noPairedDevices": "No paired devices found",
|
||||
"deviceName": "Device name",
|
||||
"pairingDate": "Pairing date",
|
||||
"platform": "Platform",
|
||||
"disconnect": "Disconnect",
|
||||
"gotIt": "Got it",
|
||||
"install": "Install",
|
||||
"2faAuthenticator2FAS": "2FA Authenticator (2FAS)",
|
||||
"inActiveTabInfo": "Please refresh this tab to use the 2FAS Browser Extension",
|
||||
"installTitle": "2FAS Browser Extension | Configuration",
|
||||
"installH1": "To start, you need to pair this extension with the 2FAS mobile application.",
|
||||
"installAppInstalled": "I've installed the app",
|
||||
"installScan": "Scan this code with your 2FAS mobile app",
|
||||
"installStep1": "Open the 2FAS mobile app",
|
||||
"installStep2": "Go to Settings → Browser Extension",
|
||||
"installStep3": "Tap \"Pair with web browser\" and scan the QR code",
|
||||
"installSuccessHeader": "2FAS Browser Extension is successfully paired with your 2FAS app",
|
||||
"installSuccessSubheader": "Now you can quickly autofill Two-Factor forms with mobile app confirmation.",
|
||||
"installStart": "Learn how it works",
|
||||
"installGoToSettings": "Go to settings",
|
||||
"installQuestions": "Any questions? Read our",
|
||||
"installBackToStep1": "Back to step 1",
|
||||
"installQRTimeoutText": "The QR code has expired",
|
||||
"installQRTimeoutButton": "Click here to regenerate",
|
||||
"appDesc": "2FAS Browser Extension is simple, private, and secure: 1 click, 1 tap, and your token is automatically entered!",
|
||||
"shortcutDesc": "Send a request to 2FAS",
|
||||
"january": "January",
|
||||
"february": "February",
|
||||
"march": "March",
|
||||
"april": "April",
|
||||
"may": "May",
|
||||
"june": "June",
|
||||
"july": "July",
|
||||
"august": "August",
|
||||
"september": "September",
|
||||
"october": "October",
|
||||
"november": "November",
|
||||
"december": "December",
|
||||
"errorGeneralTitle": "Error",
|
||||
"errorGeneralMessage": "Please refresh and try again.",
|
||||
"errorUndefinedErrorTitle": "Something went wrong",
|
||||
"errorUndefinedErrorMessage": "Please refresh and try again.",
|
||||
"errorTimeoutTitle": "Timeout",
|
||||
"errorTimeoutMessage": "Closed connection due to a time limit. Please click regenerate button to try again.",
|
||||
"errorPushExpiredTitle": "Push expired for DOMAIN",
|
||||
"errorPushExpiredMessage": "Please try again.",
|
||||
"errorWebSocketTitle": "WebSocket Error",
|
||||
"errorWebSocketMessage": "Something went wrong with the WebSocket request. Please try again.",
|
||||
"errorOnInstallErrorTitle": "Something went wrong",
|
||||
"errorOnInstallErrorMessage": "Please restart your browser or reinstall the extension.",
|
||||
"errorExtNameRequiredTitle": "Extension name required",
|
||||
"errorExtNameRequiredMessage": "Please enter the extension name.",
|
||||
"errorExtNameMinLengthTitle": "Extension name is too short",
|
||||
"errorExtNameMinLengthMessage": "Please enter the extension name with at least 3 characters.",
|
||||
"errorExtNameMaxLengthTitle": "Extension name is too long",
|
||||
"errorExtNameMaxLengthMessage": "Please enter the extension name with no more than 32 characters.",
|
||||
"errorConfigFirstTitle": "Configuration required",
|
||||
"errorConfigFirstMessage": "Please configure 2FAS Extension first.",
|
||||
"errorRemoveDeviceBadDataTitle": "Device data error",
|
||||
"errorRemoveDeviceBadDataMessage": "Please refresh and try again.",
|
||||
"errorStorageCorruptedTitle": "Extension storage is corrupted",
|
||||
"errorStorageCorruptedMessage": "We will try to fix it for you. Please wait.",
|
||||
"errorInactiveTabTitle": "Inactive tab",
|
||||
"errorInactiveTabMessage": "Please refresh this tab to use the 2FAS Browser Extension.",
|
||||
"errorLackOfTabTitle": "Your tab has been closed",
|
||||
"errorLackOfTabMessage": "The request will be ignored",
|
||||
"warningTooSoonTitle": "Wait a moment",
|
||||
"warningTooSoonMessage": "Please wait DIFF seconds before sending another request.",
|
||||
"warningSelectInputTitle": "Select the text field first",
|
||||
"warningSelectInputMessage": "Select the text field for the 2FA token then click the extension icon or use the chosen shortcut.",
|
||||
"successPushSentTitle": "Push sent",
|
||||
"successPushSentMessage": "Please check your phone and accept your login request.",
|
||||
"successExtNameUpdatedTitle": "Success",
|
||||
"successExtNameUpdatedMessage": "Extension name updated",
|
||||
"successDeviceDisconnectedTitle": "Success",
|
||||
"successDeviceDisconnectedMessage": "Device disconnected",
|
||||
"successSafariResetTitle": "Success",
|
||||
"successSafariResetMessage": "Browser Extension configuration removed",
|
||||
"infoNativeNotificationsTitle": "2FAS Notifications",
|
||||
"infoNativeNotificationsMessage": "From now on, you'll be receiving system notifications instead of 2FAS custom ones. If you'd like to change this, go to the ",
|
||||
"infoEnabledNativeNotifications": "extension's settings",
|
||||
"infoUnsupportedProtocolTitle": "Info",
|
||||
"infoUnsupportedProtocolMessage": "Only HTTP and HTTPS protocols are supported by 2FAS Extension",
|
||||
"infoBrowserActionWithoutTabTitle": "Info",
|
||||
"infoBrowserActionWithoutTabMessage": "Using outside the browser is not supported by 2FAS Extension",
|
||||
"infoTestTitle": "2FAS Notification",
|
||||
"infoTestMessage": "Hi! This is just a test",
|
||||
"optionsTitle": "2FAS Browser Extension | Options",
|
||||
"optionsHeader": "2FAS Browser Extension Settings",
|
||||
"optionsIntroHeader": "Introduction to 2FAS Browser Extension",
|
||||
"optionsIntro": "Intro",
|
||||
"optionsSettings": "Settings",
|
||||
"optionsAbout": "About 2FAS",
|
||||
"optionsDonate": "Donate",
|
||||
"optionsPairedHeader": "Paired devices:",
|
||||
"optionsAddAnotherDevice": "Add another device",
|
||||
"optionsLogsLabel": "Approve 2FAS Browser Extension logs",
|
||||
"optionsLogsDesc": "Help us improve our browser extension by approving anonymous logs from your browser regarding 2FAS Browser Extension errors only.",
|
||||
"optionsContextMenuLabel": "Show 2FAS Browser Extension option in context menu",
|
||||
"optionsPushDesc": "Choose a notification mechanism which will prompt you about communication with the 2FAS mobile app when you use this browser extension.",
|
||||
"optionsPushCustom": "2FAS Custom Notifications",
|
||||
"optionsPushNative": "Native Browser's Notifications",
|
||||
"optionsPushTest": "Test push Notification",
|
||||
"optionsPushConfigDesc1": "Native Browser's Notifications do not work?",
|
||||
"optionsPushConfigDesc2": "Make sure they are enabled in the system settings",
|
||||
"optionsShortcutFirefoxDesc": "To set or change this shortcut go to your browser settings, and extensions, then click on the gear icon and choose “Manage Extension Shortcuts.”",
|
||||
"optionsPinHeader": "Pin 2FAS for faster authentication",
|
||||
"optionsPinDesc": "Check the Extension List to make it visible.",
|
||||
"optionsPinSafariStep1": "Right click on the address bar, select Toolbar customization",
|
||||
"optionsPinSafariStep2": "Find 2FAS icon on the list, drag it to the toolbar",
|
||||
"optionsPinOperaStep2Header": "Find added Extension on the list and click “Details”.",
|
||||
"optionsPinOperaStep2SubHeader": "Then turn on “Allow on site with finding results”.",
|
||||
"optionsPinSafariToolbarCustomization": "Toolbar customization",
|
||||
"optionsDangerZone": "Danger Zone",
|
||||
"optionsSafariResetDesc": "By resetting the extension you'll erase all your 2FAS Browser Extension settings and paired devices. Do so, if you're absolutely sure and aware of losing your settings and paired devices with the 2FAS Browser Extension! This action is not reversible!",
|
||||
"optionsSafariReset": "Reset Browser Extension"
|
||||
}
|
50
webpack/utils/locoExport.js
Normal file
50
webpack/utils/locoExport.js
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
|
||||
// Copyright © 2023 Two Factor Authentication Service, Inc.
|
||||
// Contributed by Grzegorz Zając. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
const fs = require('node:fs');
|
||||
const readdir = require('node:fs').promises.readdir;
|
||||
|
||||
const getDirectories = async source =>
|
||||
(await readdir(source, { withFileTypes: true }))
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
getDirectories('./src/_locales')
|
||||
.then(locales => {
|
||||
return locales.map(locale => {
|
||||
return {
|
||||
locale,
|
||||
files: fs.readdirSync(`./src/_locales/${locale}`)
|
||||
};
|
||||
})
|
||||
})
|
||||
.then(res => {
|
||||
return res.map(l => {
|
||||
return {
|
||||
locale: l.locale,
|
||||
content: Object.assign(...l.files.map(f => {
|
||||
f = JSON.parse(fs.readFileSync(`./src/_locales/${l.locale}/${f}`, 'utf8'));
|
||||
return f;
|
||||
}))
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(res => {
|
||||
fs.writeFileSync('./webpack/utils/export/messages.json', JSON.stringify(res[0].content, null, 2));
|
||||
});
|
96
webpack/utils/locoImport.js
Normal file
96
webpack/utils/locoImport.js
Normal file
@ -0,0 +1,96 @@
|
||||
//
|
||||
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
|
||||
// Copyright © 2023 Two Factor Authentication Service, Inc.
|
||||
// Contributed by Grzegorz Zając. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
require('dotenv').config();
|
||||
const fs = require('node:fs');
|
||||
const readdir = require('node:fs').promises.readdir;
|
||||
|
||||
const getDirectories = async source =>
|
||||
(await readdir(source, { withFileTypes: true }))
|
||||
.filter(dirent => dirent.isDirectory())
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
let locoContent = {};
|
||||
let locales = [];
|
||||
const keys = {};
|
||||
const files = {};
|
||||
|
||||
const urls = {
|
||||
en: `https://localise.biz/api/export/locale/en.json?key=${process.env.LOCO_KEY}`
|
||||
};
|
||||
|
||||
const fetchConfig = {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
};
|
||||
|
||||
Promise.all(Object.keys(urls).map(locale => {
|
||||
return fetch(urls[locale], fetchConfig).then(async res => {
|
||||
return {
|
||||
[locale]: await res.json()
|
||||
}
|
||||
});
|
||||
})).then(res => Object.assign({}, ...res))
|
||||
.then(res => {
|
||||
locoContent = res;
|
||||
return getDirectories('./src/_locales');
|
||||
})
|
||||
.then(res => {
|
||||
locales = res;
|
||||
return fs.readdirSync(`./src/_locales/${locales[0]}`);
|
||||
})
|
||||
.then(fileNames => {
|
||||
return fileNames.forEach(fileName => {
|
||||
return locales.forEach(locale => {
|
||||
const f = JSON.parse(fs.readFileSync(`./src/_locales/${locale}/${fileName}`, 'utf8'));
|
||||
|
||||
if (!files[locale]) {
|
||||
files[locale] = {};
|
||||
}
|
||||
|
||||
files[locale][fileName] = f;
|
||||
keys[fileName] = Object.keys(f);
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
return Object.keys(keys).forEach(fileName => {
|
||||
return keys[fileName].forEach(key => {
|
||||
return locales.forEach(locale => {
|
||||
if (locoContent[locale][key]) {
|
||||
files[locale][fileName][key] = locoContent[locale][key];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
// console.log(files);
|
||||
|
||||
return Object.keys(files).forEach(locale => {
|
||||
return Object.keys(files[locale]).forEach(fileName => {
|
||||
const data = JSON.stringify(files[locale][fileName], null, 2);
|
||||
fs.writeFileSync(`./src/_locales/${locale}/${fileName}`, data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Przelecieć po wszystkich locale'ach i po wszystkich kluczach i dopisać do files
|
||||
// Zapisać do jsonów
|
||||
// Test z wieloma językami
|
Loading…
Reference in New Issue
Block a user