Skip to content

Commit

Permalink
Merge branch 'pr/1458' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Jan 9, 2024
2 parents 8546318 + 6826155 commit 1b22f6e
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 2,310 deletions.
27 changes: 20 additions & 7 deletions activities/Calculate.activity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

<link rel="stylesheet" href="css/activity.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="prefetch" type="application/l10n" href="translate.ini" />
<link rel="stylesheet" href="css/introjs.css">
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="lib/intro.js"></script>
Expand All @@ -21,11 +20,11 @@
<body id="body" style="background-color:#fff; color:#fff; height:100%; margin:0;">
<div id="main-toolbar" class="toolbar">
<button class="toolbutton" id="activity-button" title="My Activity"></button>
<button class="toolbutton" id="trigo-palette" data-l10n-id="trigo" title="Select Trigonometric Function"></button>
<button class="toolbutton" id="algebra-palette" data-l10n-id="algebra" title="Select Algebra Type"></button>
<button class="toolbutton" id="base-palette" data-l10n-id="base" title="Select Base"></button>
<button class="toolbutton" id="radian-degree-palette" data-l10n-id="angle" title="Select Angle Type"></button>
<button class="toolbutton" id="output-digits-palette" data-l10n-id="digit" title="Select Output Digits"></button>
<button class="toolbutton" id="trigo-palette" data-i18n="trigo" title="Select Trigonometric Function"></button>
<button class="toolbutton" id="algebra-palette" data-i18n="algebra" title="Select Algebra Type"></button>
<button class="toolbutton" id="base-palette" data-i18n="base" title="Select Base"></button>
<button class="toolbutton" id="radian-degree-palette" data-i18n="angle" title="Select Angle Type"></button>
<button class="toolbutton" id="output-digits-palette" data-i18n="digit" title="Select Output Digits"></button>
<button class="toolbutton pull-right" id="stop-button" title="Stop"></button>
<button class="toolbutton pull-right" id="fullscreen-button" title="Fullscreen"></button>
<button class="toolbutton pull-right" id="help-button" title="Tutorial"></button>
Expand Down Expand Up @@ -116,5 +115,19 @@
<div id="plot"></div>
</div>
</body>

<script type="text/javascript">
requirejs.config({
baseUrl: "js",
paths: {
activity: "../js"
}
});
var l10n = null;
requirejs(["../lib/l10n"], function (il10n) {
l10n = il10n;
});
window.addEventListener('localized', function() {
l10n.updateDocument();
}, false);
</script>
</html>
33 changes: 15 additions & 18 deletions activities/Calculate.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,20 @@ define(["sugar-web/activity/activity","mustache","sugar-web/graphics/palette","a
CalculateApp.libs.activity = activity;
CalculateApp.libs.mustache = mustache;

requirejs(['domReady!', 'activity/trigo-palette', 'activity/algebra-palette', 'webL10n', 'sugar-web/datastore', "tutorial"], function(doc, trigoPaletteLib, algebraPaletteLib, webL10n, datastore, tutorial) {
CalculateApp.libs.webL10n = webL10n;
requirejs(['domReady!', 'activity/trigo-palette', 'activity/algebra-palette', 'l10n', 'sugar-web/datastore', "tutorial", "sugar-web/env"], function(doc, trigoPaletteLib, algebraPaletteLib, l10n, datastore, tutorial, env) {

//Localization handling
env.getEnvironment(function(err, environment) {
var defaultLanguage = (typeof chrome != 'undefined' && chrome.app && chrome.app.runtime) ? chrome.i18n.getUILanguage() : navigator.language;
var language = environment.user ? environment.user.language : defaultLanguage;
l10n.init(language);
});

window.addEventListener("localized", function() {
CalculateApp.translateGui();
});

CalculateApp.libs.l10n = l10n;
CalculateApp.libs.trigopalette = trigoPaletteLib;
CalculateApp.libs.algebrapalette = algebraPaletteLib;

Expand All @@ -27,22 +39,7 @@ define(["sugar-web/activity/activity","mustache","sugar-web/graphics/palette","a
tutorial.start();
});

//Localization handling
window.addEventListener('localized', function() {
if (datastore !== undefined && datastore.localStorage !== undefined) {
var preferences = datastore.localStorage.getValue('sugar_settings');
if (preferences === null || preferences.name === undefined) {
return;
}
if (preferences.language !== undefined) {
if (CalculateApp.libs.webL10n.language.code !== preferences.language)
CalculateApp.libs.webL10n.language.code = preferences.language;
}
}

CalculateApp.transateGui();
}, false);


//We auto focus if needed
CalculateApp.focus();

Expand Down
14 changes: 7 additions & 7 deletions activities/Calculate.activity/js/calculate-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ var CalculateApp = {
},

/* Translation of the Gui */
transateGui: function() {
if (CalculateApp.libs.webL10n.get("calcul") !== undefined && CalculateApp.libs.webL10n.get("calcul").length > 0) {
CalculateApp.elements.calcInput.placeholder = CalculateApp.libs.webL10n.get("calcul");
translateGui: function() {
if (CalculateApp.libs.l10n.get("calcul") !== undefined && CalculateApp.libs.l10n.get("calcul").length > 0) {
CalculateApp.elements.calcInput.placeholder = CalculateApp.libs.l10n.get("calcul");
}
if (CalculateApp.libs.webL10n.get("label") !== undefined && CalculateApp.libs.webL10n.get("label").length > 0) {
CalculateApp.elements.labelInput.placeholder = CalculateApp.libs.webL10n.get("label");
if (CalculateApp.libs.l10n.get("label") !== undefined && CalculateApp.libs.l10n.get("label").length > 0) {
CalculateApp.elements.labelInput.placeholder = CalculateApp.libs.l10n.get("label");
}
if (CalculateApp.libs.webL10n.get("clear") !== undefined && CalculateApp.libs.webL10n.get("clear").length > 0) {
CalculateApp.elements.calcButtonClear.innerHTML = CalculateApp.libs.webL10n.get("clear");
if (CalculateApp.libs.l10n.get("clear") !== undefined && CalculateApp.libs.l10n.get("clear").length > 0) {
CalculateApp.elements.calcButtonClear.innerHTML = CalculateApp.libs.l10n.get("clear");
}
},

Expand Down
3 changes: 3 additions & 0 deletions activities/Calculate.activity/lib/axios.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions activities/Calculate.activity/lib/i18next.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 1b22f6e

Please sign in to comment.