Skip to content

Commit

Permalink
feat(language): skizzle now support many languages (it's just french …
Browse files Browse the repository at this point in the history
…and english at this moment)
  • Loading branch information
Debaerdm committed Sep 18, 2020
1 parent 04616f8 commit 19baa5e
Show file tree
Hide file tree
Showing 37 changed files with 2,260 additions and 705 deletions.
1,027 changes: 1,020 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@commitlint/config-conventional": "^9.1.1",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-typescript": "^5.0.2",
"@testing-library/jest-dom": "^5.11.2",
"@testing-library/svelte": "^3.0.0",
Expand Down Expand Up @@ -93,6 +94,7 @@
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",
"rollup": "^2.23.1",
"rollup-plugin-filesize": "^9.0.2",
"rollup-plugin-livereload": "^1.3.0",
"rollup-plugin-svelte": "5.2.3",
"rollup-plugin-terser": "6.1.0",
Expand Down
71 changes: 71 additions & 0 deletions public/assets/langs/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"About Application": "About Application",
"Quit": "Quit",
"Edit": "Edit",
"Undo": "Undo",
"Redo": "Redo",
"Cut": "Cut",
"Copy": "Copy",
"Paste": "Paste",
"Select All": "Select All",
"Open devtool": "Open devlopment tool",
"Reload application": "Reload application",
"UpdateDevMode": "Development mode, skip the update",
"UpdateError": "An error occurred during the update.",
"UpdateCheck": "Check for update...",
"UpdateAvailable": "An update is available",
"UpdateNotAvailable": "Your app is up to date",
"UpdateDownloading": "Downloading...",
"UpdateDownloaded": "Install the update",
"UpdateNotified": "Restart in $0 second$1",
"Offline": "You'r already offline. The list cannot be refreshed and some features are disabled.",
"Retry": "Retry",
"Refresh": "Refresh",
"Updating": "Updating...",
"ViewFullList": "View full list",
"FilterList": "Filter list",
"less": "less",
"more": "more",
"show": "Show",
"PullRequestsError": "Unable to retrieve your pull requests.",
"PullRequestsEmpty": "There are no pull requests in your projects at the moment.",
"ProfileNotFound": "Unable to load your profile.",
"Menu": "Menu",
"Projects": "Projects",
"Settings": "Settings",
"NoProject": "No project",
"OneProject": "1 Project",
"Search": "Search",
"NoProjectOnOrganization": "The currently selected organizations do not contain any projects.",
"Today": "Today",
"Yesterday": "Yesterday",
"Time": "$0 days ago",
"AutoComplete": "Auto complete",
"Draft": "Draft",
"Conflicts": "Conflicts",
"NoRepository": "No repository for this project.",
"Back": "Back",
"ProjectsOrganizations": "Select the organizations for which you want to see projects.",
"OrganizationsEmpty": "There is no valid organization on your account.",
"Manually": "Manually",
"EveryMinutes": "Every $0 minutes",
"LaunchStartup": "Launch the application on startup",
"ConfigTheme": "Pick your theme.",
"Version": "Version",
"SignOut": "Sign out",
"Theme": "Theme",
"Organizations": "Organizations",
"StartUp": "Start-up",
"Refreshment": "Refreshment",
"HideMenu": "Hide menu",
"Login": "Skizzle allows you to group the pull requests of your teams. <br/>To get started <b>log in</b> with your account.",
"Globals": "General",
"Languages": "Languages",
"ChooseLanguage": "Choose your language",
"DefaultValue": "Choose a value",
"Loading": "Loading...",
"Yes": "Yes, I do",
"No": "No, thanks",
"ChangingLanguageTitle": "Do you want to change your language?",
"ChangingLanguageMessage": "Are you going to change your language? (This requires a reboot of the application)"
}
71 changes: 71 additions & 0 deletions public/assets/langs/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"About Application": "A propos de l'application",
"Quit": "Quitter",
"Edit": "Editer",
"Undo": "Annuler",
"Redo": "Refaire",
"Cut": "Couper",
"Copy": "Copier",
"Paste": "Coller",
"Select All": "Tout selectionnée",
"Open devtool": "Ouvrir la console de developpement",
"Reload application": "Recharger l'application",
"UpdateDevMode": "Mode de développement, passage de l'étape de mise à jour",
"UpdateError": "Une erreur s'est produite lors de la mise à jour.",
"UpdateCheck": "Recherche de mise à jour...",
"UpdateAvailable": "Une mise à jour est disponible",
"UpdateNotAvailable": "Votre application est à jour",
"UpdateDownloading": "Téléchargement en cours...",
"UpdateDownloaded": "Installation de la mise à jour.",
"UpdateNotified": "Redémarrage dans $0 seconde$1",
"Offline": "Vous n'êtes pas connecté à Internet. Il est impossible de rafraîchir la liste et certaines fonctionnalités sont désactivées.",
"Retry": "Réessayer",
"Refresh": "Rafraîchir",
"Updating": "Mise à jour...",
"ViewFullList": "Afficher la liste complète",
"FilterList": "Filtrer la liste",
"less": "moins",
"more": "plus",
"show": "Voir",
"PullRequestsError": "Impossible de récupérer vos pull requests.",
"PullRequestsEmpty": "Il n'y a aucune pull request dans vos projets pour le moment.",
"ProfileNotFound": "Impossible de charger votre profil.",
"Menu": "Menu",
"Projects": "Projets",
"Settings": "Réglagles",
"NoProject": "Aucun projet",
"OneProject": "1 Projet",
"Search": "Chercher",
"NoProjectOnOrganization": "Les organisations actuellement selectionnées ne contiennent aucun projet.",
"Today": "Aujourd'hui",
"Yesterday": "Hier",
"Time": "il y a $0 jours",
"AutoComplete": "Saisie automatique",
"Draft": "Brouillon",
"Conflicts": "Conflits",
"NoRepository": "Aucun repository pour ce projet.",
"Back": "Retour",
"ProjectsOrganizations": "Sélectionnez les organisations pour lesquelles vous voulez voir les projets.",
"OrganizationsEmpty": "Il n'y a aucune organisation valide sur votre compte.",
"Manually": "Manuellement",
"EveryMinutes": "Toutes les $0 minutes",
"LaunchStartup": "Lancer l'application au démarrage",
"ConfigTheme": "Choisissez votre thème.",
"Version": "Version",
"SignOut": "Se déconnecter",
"Theme": "Theme",
"Organizations": "Organisations",
"StartUp": "Démarrage",
"Refreshment": "Rafraîchissement",
"HideMenu": "Masquer le menu",
"Login": "Skizzle vous permet de regrouper les pull requests de vos équipes. <br/>Pour commencer <b>connectez vous</b> avec votre compte.",
"Globals": "Général",
"Languages": "Langages",
"ChooseLanguage": "Choisissez votre langage",
"DefaultValue": "Choisissez une valeur",
"Loading": "Chargement...",
"Yes": "Oui, je le veux",
"No": "Non, merci",
"ChangingLanguageTitle": "Voulez-vous changer de langage ?",
"ChangingLanguageMessage": "Vous allez changer de langage ? (Cela nécéssite un redémarrage de l'application)"
}
12 changes: 12 additions & 0 deletions public/assets/langs/langs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"code": "EN",
"label": "English",
"words": "assets/langs/en.json"
},
{
"code": "FR",
"label": "Français",
"words": "assets/langs/fr.json"
}
]
105 changes: 91 additions & 14 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const fs = require('fs');
const path = require('path');
const unhandled = require('electron-unhandled');
const contextMenu = require('electron-context-menu');
const log = require('electron-log');
const { openNewGitHubIssue, debugInfo, is } = require('electron-util');
const debug = require('electron-debug');
const electron = require('electron');
Expand Down Expand Up @@ -48,6 +51,7 @@ const config = {
scope:
'vso.analytics vso.build vso.code vso.connected_server vso.dashboards vso.entitlements vso.extension vso.extension.data vso.graph vso.identity vso.loadtest vso.machinegroup_manage vso.memberentitlementmanagement vso.notification vso.packaging vso.project vso.release vso.securefiles_read vso.serviceendpoint vso.symbols vso.taskgroups_read vso.test vso.variablegroups_read vso.wiki vso.work',
};
const directory = '/assets/langs/';

let proxyLogin = null;
let proxyPassword = null;
Expand All @@ -56,6 +60,23 @@ let authWindow;
let logoutWindow;
let splashscreen;
let tray;
let translate;

function getWord(word, ...format) {
let translation = translate.words[word];

if (translation === undefined) {
translation = word;
}

if (translation && format) {
for (let i = 0; i < format.length + 1; i++) {
translation = translation.replace('$' + i, format[i]);
}
}

return translation;
}

function createSplashScreen() {
splashscreen = new BrowserWindow({
Expand All @@ -80,7 +101,7 @@ function createSplashScreen() {
function hangOrCrash() {
const options = {
type: 'info',
title: 'Renderer PRocess Hanging',
title: 'Renderer Process Hanging',
message: 'This process is hanging.',
buttons: ['Reload', 'Close'],
};
Expand Down Expand Up @@ -133,12 +154,12 @@ function createWindow() {
label: 'Application',
submenu: [
{
label: 'About Application',
label: getWord('About Application'),
selector: 'orderFrontStandardAboutPanel:',
},
{ type: 'separator' },
{
label: 'Quit',
label: getWord('Quit'),
accelerator: 'Command+Q',
click() {
app.quit();
Expand All @@ -147,34 +168,39 @@ function createWindow() {
],
},
{
label: 'Edit',
label: getWord('Edit'),
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ label: getWord('Undo'), accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{
label: getWord('Redo'),
accelerator: 'Shift+CmdOrCtrl+Z',
selector: 'redo:',
},
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: getWord('Cut'), accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: getWord('Copy'), accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: getWord('Paste'), accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{
label: 'Select All',
label: getWord('Select All'),
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:',
},
],
},
{
label: 'Ouvrir la console de développement',
label: getWord('Open devtool'),
click: () => window.webContents.openDevTools({ mode: 'detach' }),
accelerator: 'CommandOrControl+O',
visible: is.development,
},
{
label: "Recharger l'application",
label: getWord('Reload application'),
click: () => window.reload(),
accelerator: 'F5',
},
{ type: 'separator' },
{
label: 'Quitter',
label: getWord('Quit'),
click: () => app.quit(),
accelerator: 'CommandOrControl+Q',
},
Expand Down Expand Up @@ -219,8 +245,27 @@ if (!gotTheLock) {

app.commandLine.appendSwitch('disable-site-isolation-trials');
app.on('ready', () => {
let argv = process.argv;
let lang = argv.find(x => x.startsWith('--skizzle-language='));
let currentLanguage = app.getLocale();

if (lang) {
currentLanguage = lang.split('=')[1];
}

let languages = JSON.parse(
fs.readFileSync(`${__dirname}/assets/langs/langs.json`, 'utf8'),
).find(x => x.code === currentLanguage.toUpperCase());

translate = {
...languages,
words: JSON.parse(
fs.readFileSync(`${__dirname}/${languages.words}`, 'utf8'),
),
};

createSplashScreen();
checkForUpdates(splashscreen, createWindow);
checkForUpdates(splashscreen, createWindow, getWord);
});

app.on('window-all-closed', () => {
Expand All @@ -245,6 +290,38 @@ if (!gotTheLock) {
}
});

ipcMain.on('update-language', (event, loadedLanguage) => {
translate = loadedLanguage;
let argv = [...process.argv.slice(1)];

let exist = argv.findIndex(x => x.startsWith('--skizzle-language='));

if (exist !== -1) {
argv = argv.filter(x => !x.startsWith('--skizzle-language='));
}

const response = dialog.showMessageBoxSync(window, {
buttons: [getWord('Yes'), getWord('No')],
type: 'question',
title: getWord('ChangingLanguageTitle'),
message: getWord('ChangingLanguageMessage'),
cancelId: 2,
});

if (response === 0) {
event.sender.send('update-language-res', true);

setTimeout(() => {
app.relaunch({
args: [...argv, '--skizzle-language=' + loadedLanguage.code],
});
app.exit(0);
}, 1000);
} else {
event.sender.send('update-language-res', false);
}
});

ipcMain.on('mentioned', (event, args) => {
const { body, title, pullRequestId } = args;

Expand Down
4 changes: 1 addition & 3 deletions public/splashscreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
src="./assets/logo-skizzle-dark-context.svg"
alt="Skizzle"
/>
<p class="skz-splashscreen__label">
Chargement...
</p>
<p class="skz-splashscreen__label"></p>
<div class="skz-splashscreen__progress">
<div class="skz-splashscreen__progress--bar"></div>
</div>
Expand Down
Loading

0 comments on commit 19baa5e

Please sign in to comment.