Verified Commit e735fcee authored by Booteille's avatar Booteille

Add i18n support, use native locale names in subtitles dropdowns

parent 8aa75dcc
......@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Updated uMatrix recipe
- List subtitles by native name
- Internationalization support! Supported languages are english and french.
## [0.7.3] - 2019-04-09
### Added
......
{
"extName": {
"message": "Invidition",
"description": "Extension name."
},
"extShotDesc": {
"message": "Redirects YouTube links and embeds to their Invidious counterpart without any call to YouTube.",
"description": "This will be in the store. Must be 132 characters or less."
},
"settingsInstancesListHint": {
"message": "You can find a list of different Invidious instances <a href=\"https://github.com/omarroth/invidious/wiki/Invidious-Instances\" alt=\"Existing instances\">here</a>.",
"description": "Displays a Hint indicating differents instances exist"
},
"settingsFormInstanceLabel": {
"message": "Instance:"
},
"settingsFormProxyTitle": {
"message": "Activating this option will force the use of Invidious proxy."
},
"settingsFormProxyLabel": {
"message": "Force Proxy<sup>?</sup>:"
},
"settingsFormAutoplayLabel": {
"message": "Autoplay:"
},
"settingsFormDefaultCaptionsLabel": {
"message": "Default Captions:"
},
"settingsFormSaveButton": {
"message": "Save"
}
}
{
"extName": {
"message": "Invidition",
"description": "Extension name."
},
"extShortDesc": {
"message": "Redirige les liens et lecteurs imbriqués YouTube vers leur équivalent Invidious sans faire aucun appel à YouTube !",
"description": "This will be in the store. Must be 132 characters or less."
},
"settingsInstancesListHint": {
"message": "Vous trouverez une liste des différentes instances <a href=\"https://github.com/omarroth/invidious/wiki/Invidious-Instances\" alt=\"Existing instances\">ici</a>.",
"description": "Displays a Hint indicating differents instances exist"
},
"settingsFormInstanceLabel": {
"message": "Instance :"
},
"settingsFormProxyLabel": {
"message": "Forcer l'utilisation du Proxy<sup>?</sup> :"
},
"settingsFormProxyTitle": {
"message": "Activer cette option forcera l'utilisation du proxy d'Invidious."
},
"settingsFormAutoplayLabel": {
"message": "Lecture automatique :"
},
"settingsFormDefaultCaptionsLabel": {
"message": "Sous-titres par défaut :"
},
"settingsFormSaveButton": {
"message": "Enregistrer"
}
}
{
"manifest_version": 2,
"name": "Invidition",
"name": "__MSG_extName__",
"version": "0.7.3",
"description": "Redirects YouTube links and embeds to their Invidious counterpart without any call to YouTube.",
"description": "__MSG_extShortDesc__",
"homepage_url": "https://gitlab.com/Booteille/Invidition",
"default_locale": "en",
"permissions": [
"activeTab",
"tabs",
......
{
"name": "invidition",
"version": "0.7.2",
"version": "0.7.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
import * as _ from 'lodash';
import * as browser from 'webextension-polyfill';
export const insertI18nContentIntoDocument = (document) => {
let elements = document.querySelectorAll('[data-i18n-content]');
_.forEach(elements, (el) => {
let messageName = el.getAttribute('data-i18n-content');
el.innerHTML = browser.i18n.getMessage(messageName);
});
};
export const insertI18nTitleIntoDocument = (document) => {
let elements = document.querySelectorAll('[data-i18n-title]');
_.forEach(elements, (el) => {
let messageName = el.getAttribute('data-i18n-title');
el.setAttribute('title', browser.i18n.getMessage(messageName));
});
};
......@@ -6,23 +6,37 @@
</head>
<body>
<p>You can find a list of different Invidious instances <a href="https://github.com/omarroth/invidious/wiki/Invidious-Instances" alt="invidious instances">here</a>.</p>
<section class="notice notice-info">
<div class="notice-head">
<span data-i18n-content="settingsInstancesListHint"></span>
</div>
</section>
<form>
<label for="instance">Instance:</label>
<label for="instance">
<span data-i18n-content="settingsFormInstanceLabel"></span>
</label>
<input type="url" id="instance"><br><br>
<label for="local" title="Activating this option will force the use of Invidious proxy, even when you already loaded the page." alt="Activating this option will force the use of Invidious proxy." class="tooltip">Force Proxy<sup>?</sup></label>
<label for="local" data-i18n-title="settingsFormProxyTitle">
<span data-i18n-content="settingsFormProxyLabel"></span>
</label>
<input type="checkbox" name="local" id="local"><br><br>
<label for="autoplay">Autoplay:</label>
<label for="autoplay">
<span data-i18n-content="settingsFormAutoplayLabel"></span>
</label>
<input type="checkbox" name="autoplay" id="autoplay"><br><br>
<label for="defaultCaptions1">Default Captions:</label>
<label for="defaultCaptions1">
<span data-i18n-content="settingsFormDefaultCaptionsLabel"></span>
</label>
<select name="defaultCaptions1" class="defaultCaptions" id="defaultCaptions1"></select>
<select name="defaultCaptions2" class="defaultCaptions" id="defaultCaptions2"></select>
<select name="defaultCaptions3" class="defaultCaptions" id="defaultCaptions3"></select><br><br>
<button type="submit">Save</button>
<button class="dictString" data-dict="settingsFormSaveButton" type="submit">
<span data-i18n-content="settingsFormSaveButton"></span>
</button>
</form>
<script src="/dist/vendors.js"></script>
......
......@@ -3,6 +3,8 @@ import * as browser from 'webextension-polyfill';
import * as _ from 'lodash';
import ISO6391 from 'iso-639-1';
import { MessageType } from './lib/types';
import Vue from 'vue';
import * as helpers from './lib/helpers';
// When saving options
function saveOptions(e) {
......@@ -82,7 +84,7 @@ function restoreOptions() {
_.forEach(ISO6391.getAllCodes(), (code) => {
let option: HTMLOptionElement = document.createElement("OPTION") as HTMLOptionElement;
option.value = code;
option.innerHTML = ISO6391.getName(code);
option.innerHTML = ISO6391.getNativeName(code);
element.append(option);
})
......@@ -103,5 +105,11 @@ const captionsQuery = (): string => {
return query.substr(0, query.length -1);
}
const insertI18nIntoDocument = () => {
helpers.insertI18nTitleIntoDocument(document);
helpers.insertI18nContentIntoDocument(document);
}
document.addEventListener("DOMContentLoaded", insertI18nIntoDocument);
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment