mirror of
https://github.com/dualshock-tools/dualshock-tools.github.io.git
synced 2026-03-01 11:19:54 +03:00
Add and remove translated strings
This commit is contained in:
committed by
dualshock-tools
parent
8b7e8425de
commit
50dcc191e8
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import { sleep, float_to_str, dec2hex, dec2hex32, lerp_color, la, createCookie, readCookie } from './utils.js';
|
||||
import { sleep, float_to_str, dec2hex, dec2hex32, lerp_color, initAnalyticsApi, la, createCookie, readCookie } from './utils.js';
|
||||
import { initControllerManager } from './controller-manager.js';
|
||||
import ControllerFactory from './controllers/controller-factory.js';
|
||||
import { lang_init, l } from './translations.js';
|
||||
@@ -98,7 +98,8 @@ function gboot() {
|
||||
await loadAllTemplates();
|
||||
await init_svg_controller();
|
||||
|
||||
lang_init(app, handleLanguageChange, show_welcome_modal, la);
|
||||
initAnalyticsApi(app); // init just with gu for now
|
||||
lang_init(app, handleLanguageChange, show_welcome_modal);
|
||||
show_welcome_modal();
|
||||
|
||||
$("input[name='displayMode']").on('change', on_stick_mode_change);
|
||||
@@ -125,6 +126,8 @@ function gboot() {
|
||||
|
||||
async function connect() {
|
||||
app.gj = crypto.randomUUID();
|
||||
initAnalyticsApi(app); // init with gu and jg
|
||||
|
||||
// Initialize controller manager with translation function
|
||||
controller = initControllerManager({ l, handleNvStatusUpdate });
|
||||
controller.setInputHandler(handleControllerInput);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import { createCookie, readCookie } from './utils.js';
|
||||
import { la, createCookie, readCookie } from './utils.js';
|
||||
|
||||
// Alphabetical order
|
||||
const available_langs = {
|
||||
@@ -29,15 +29,13 @@ const available_langs = {
|
||||
|
||||
// Translation state - will be imported from core.js app object
|
||||
let translationState = null;
|
||||
let la = null;
|
||||
let welcomeModal = null;
|
||||
let handleLanguageChange = null;
|
||||
|
||||
export function lang_init(appState, handleLanguageChangeCb, welcomeModalCb, laCb) {
|
||||
export function lang_init(appState, handleLanguageChangeCb, welcomeModalCb) {
|
||||
translationState = appState;
|
||||
handleLanguageChange = handleLanguageChangeCb;
|
||||
welcomeModal = welcomeModalCb;
|
||||
la = laCb;
|
||||
|
||||
let id_iter = 0;
|
||||
const items = document.getElementsByClassName('ds-i18n');
|
||||
|
||||
17
js/utils.js
17
js/utils.js
@@ -81,26 +81,21 @@ export function reverse_str(s) {
|
||||
return s.split('').reverse().join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics/logging function
|
||||
* @param {string} k Key/event name
|
||||
* @param {Object} v Optional values object
|
||||
*/
|
||||
export function la(k, v = {}) {
|
||||
// Get app state from global scope if available
|
||||
if (typeof window !== 'undefined' && window.app) {
|
||||
export let la = undefined;
|
||||
export function lf(operation, data) { la(operation, buf2hex(data.buffer)); return data; }
|
||||
|
||||
export function initAnalyticsApi({gj, gu}) {
|
||||
la = (k, v = {}) => {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "https://the.al/ds4_a/l",
|
||||
data: JSON.stringify({u: window.app.gu, j: window.app.gj, k, v}),
|
||||
data: JSON.stringify({u: gu, j: gj, k, v}),
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function lf(operation, data) { la(operation, buf2hex(data.buffer)); return data; }
|
||||
|
||||
export function lerp_color(a, b, t) {
|
||||
// a, b: hex color strings, t: 0.0-1.0
|
||||
function hex2rgb(hex) {
|
||||
|
||||
Reference in New Issue
Block a user