Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Drylozu committed Jul 7, 2020
0 parents commit 4ffd0e9
Show file tree
Hide file tree
Showing 6 changed files with 7,445 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.cache
dist
build
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Open In Browser
![Made with love for Graviton](https://raw.githubusercontent.com/Graviton-Code-Editor/website/master/src/badges/made_for_graviton.svg?sanitize=true)

A simple [Graviton](https://github.com/Graviton-Code-Editor/Graviton-App) plugin to open HTML/SVG/PNG files in your preferred app (normally it's the browser).
It adds an item in the status bar, there you can open the file

### How to install it
1. Go to the [Releases Page](https://github.com/Drylotrans/OpenInBrowser/releases)
2. Download the latest version
3. Extract the content of the .zip file in `%appdata%/.graviton2/plugins`

### Supported languages:
> It will be return the English string if the Graviton's language isn't supported
- **Português brasileiro** (Brazilian Portuguese)
- **Deutsch** (German)
- **русский** (Russian)
- **Español** (Spanish)
- **Français** (French)
- **Català** (Catalan)
- **Italiano** (Italian)
- **English**

If you know a language and want to contribute, do a PR with the translated strings.
I'll appreciate it :heart:
28 changes: 28 additions & 0 deletions i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const strings = {
label: {
brazilian_portuguese: "Abra no navegador",
catalan: "Oberta al navegador",
english: "Open in browser",
french: "Ouvrir dans le navigateur",
german: "Im Browser öffnen",
italian: "Apri nel browser",
russian: "Открыть в браузере",
spanish: "Abrir en navegador",
},
hint: {
brazilian_portuguese: "Abre o arquivo atual no seu navegador padrão",
catalan: "Obre el fitxer actual al navegador predeterminat",
english: "Opens the current file in your default browser",
french: "Ouvre le fichier actuel dans votre navigateur par défaut",
german: "Öffnet die aktuelle Datei in Ihrem Standardbrowser",
italian: "Apre il file corrente nel browser predefinito",
russian: "Открывает текущий файл в браузере по умолчанию",
spanish: "Abre el archivo actual en tu navegador por defecto",
}
};

export default function translate(text, language) {
const string = strings[text][language];
if (!string) return strings[text].english;
return string;
}
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import open from "open";
import translate from "./i18n.js";

const path = window.require("path");

export function entry({ StatusBarItem, StaticConfig, RunningConfig }) {
var file;
const item = new StatusBarItem({
label: translate("label", StaticConfig.data.appLanguage),
hint: translate("hint", StaticConfig.data.appLanguage),
action: () => {
if (file)
open(file);
}
});
item.hide();
RunningConfig.on("aTabHasBeenFocused", ({ directory }) => {
const extension = path.extname(directory).toLowerCase();
if (/\.(html|png|svg)$/.test(extension)) {
file = directory;
item.show();
} else {
file = null;
item.hide();
}
});

StaticConfig.keyChanged("appLanguage", (language) => {
item.setLabel(translate("label", language));
item.setHint(translate("hint", language));
});
}
Loading

0 comments on commit 4ffd0e9

Please sign in to comment.