Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/mjs/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export const paths = {
};

export const provides = {
'startup': ['loader'],
'startup': ['loader', 'core'],
'loader': ['core'],
'input/tex': [
'input/tex-base',
'[tex]/ams',
Expand Down
13 changes: 10 additions & 3 deletions components/mjs/loader/loader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import './lib/loader.js';
import '../core/core.js';

import {Loader, CONFIG} from '#js/components/loader.js';
import {combineDefaults} from '#js/components/global.js';
import {dependencies, paths, provides} from '../dependencies.js';
import {Locale} from '#js/util/Locale.js';

Loader.preLoaded('loader', 'core');

combineDefaults(MathJax.config.loader, 'dependencies', dependencies);
combineDefaults(MathJax.config.loader, 'paths', paths);
combineDefaults(MathJax.config.loader, 'provides', provides);

Loader.load(...CONFIG.load)
.then(() => CONFIG.ready())
.catch((message, name) => CONFIG.failed(message, name));
let locale = MathJax.config.locale ?? Locale.current;
try { locale = localStorage.getitem('MathJax-locale') ?? locale; } catch (_err) {}
Locale.setLocale(locale)
.then(() => Loader.load(...CONFIG.load))
.then(() => CONFIG.ready())
.catch((message, name) => CONFIG.failed(message, name));
6 changes: 5 additions & 1 deletion components/mjs/startup/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../core/core.js';
import {combineDefaults} from '#js/components/global.js';
import {dependencies, paths, provides, compatibility} from '../dependencies.js';
import {Loader, CONFIG} from '#js/components/loader.js';
import {Locale} from '#js/util/Locale.js';

Loader.preLoaded('loader', 'startup', 'core');

Expand All @@ -14,7 +15,10 @@ combineDefaults(MathJax.config.loader, 'provides', provides);
combineDefaults(MathJax.config.loader, 'source', compatibility);

export function startup(ready) {
return Loader.load(...CONFIG.load)
let locale = MathJax.config.locale ?? Locale.current;
try { locale = localStorage.getItem('MathJax-locale') ?? locale; } catch (_err) {}
return Locale.setLocale(locale)
.then(() => Loader.load(...CONFIG.load))
.then(() => (ready || function () {})())
.then(() => CONFIG.ready())
.catch(error => CONFIG.failed(error));
Expand Down
6 changes: 6 additions & 0 deletions components/mjs/ui/menu/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"targets": ["ui/menu", "a11y/speech/SpeechMenu.ts"],
"excludeSubdirs": true
},
"copy": {
"to": "[bundle]/ui/menu",
"from": "[ts]/ui/menu",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
},
"webpack": {
"name": "ui/menu",
"libs": [
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
"=============================================================================== copy": "",
"copy:assets": "pnpm -s log:comp 'Copying assets'; copy() { pnpm -s copy:locales $1 && pnpm -s copy:mj2 $1 && pnpm -s copy:mml3 $1 && pnpm -s copy:html $1; }; copy",
"copy:html": "copy() { pnpm -s log:single 'Copying sre auxiliary files'; pnpm copyfiles -u 1 'ts/a11y/sre/*.html' 'ts/a11y/sre/require.*' $1; }; copy",
"copy:locales": "pnpm -s log:single 'Copying TeX extension locales'; copy() { pnpm copyfiles -u 3 'ts/input/tex/__locales__/*.json' 'ts/input/tex/*/__locales__/*.json' $1/input/tex/extensions; }; copy",
"copy:locales": "copy() { pnpm -s copy:locales:menu $1; pnpm -s copy:locales:tex $1; }; copy ",
"copy:locales:menu": "pnpm -s log:single 'Copying menu locales'; copy() { pnpm copyfiles -u 1 'ts/ui/menu/__locales__/*.json' $1; }; copy",
"copy:locales:tex": "pnpm -s log:single 'Copying TeX extension locales'; copy() { pnpm copyfiles -u 1 'ts/input/tex/__locales__/*.json' $1 && pnpm copyfiles -u 3 'ts/input/tex/*/__locales__/*.json' $1/input/tex/extensions; }; copy",
"copy:mj2": "copy() { pnpm -s log:single 'Copying legacy code AsciiMath'; pnpm copyfiles -u 1 'ts/input/asciimath/legacy/**/*' $1; }; copy",
"copy:mml3": "copy() { pnpm -s log:single 'Copying MathML3 extension json'; pnpm copyfiles -u 1 ts/input/mathml/mml3/mml3.sef.json $1; }; copy",
"copy:pkg": "copy() { pnpm -s log:single \"Copying package.json to $1\"; pnpm copyfiles -u 2 components/bin/package.json $1; }; copy",
Expand Down
11 changes: 6 additions & 5 deletions ts/a11y/speech/SpeechMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
SelectionGrid,
} from '../../ui/dialog/SelectionDialog.js';
import { SubMenu, Submenu } from '../../ui/menu/mj-context-menu.js';
import { localize } from '../../ui/menu/__locales__/Component.js';
import * as Sre from '../sre.js';

/**
Expand Down Expand Up @@ -127,7 +128,7 @@ function csSelectionBox(menu: MJContextMenu, locale: string): object {
});
}
const sb = new SelectionDialog(
'Clearspeak Preferences',
localize('ClearspeakTitle'),
'',
items,
SelectionOrder.ALPHABETICAL,
Expand All @@ -137,7 +138,7 @@ function csSelectionBox(menu: MJContextMenu, locale: string): object {
return {
type: 'command',
id: 'ClearspeakPreferences',
content: 'Select Preferences',
content: localize('SelectPrefs'),
action: () => sb.post(),
};
}
Expand All @@ -159,13 +160,13 @@ function basePreferences(previous: string): object[] {
const items = [
{
type: 'radio',
content: 'No Preferences',
content: localize('NoPrefs'),
id: 'clearspeak-default',
variable: 'speechRules',
},
{
type: 'radio',
content: 'Current Preferences',
content: localize('CurrentPrefs'),
id: 'clearspeak-' + previous,
variable: 'speechRules',
},
Expand All @@ -191,7 +192,7 @@ function smartPreferences(
): object[] {
const loc = localePreferences.get(locale);
const items = [
{ type: 'label', content: 'Preferences for ' + smart },
{ type: 'label', content: localize('PrefsFor', smart) },
{ type: 'rule' },
];
return items.concat(
Expand Down
2 changes: 1 addition & 1 deletion ts/components/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export abstract class Startup {
* @returns {Promise<void[]>} A promise for when the locale is loaded and ready.
*/
public static setLocale(): Promise<void[]> {
return Locale.setLocale(MathJax.config.locale || 'en');
return Locale.setLocale(MathJax.config.locale ?? Locale.current);
}

/**
Expand Down
17 changes: 10 additions & 7 deletions ts/ui/menu/MJContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { MathItem } from '../../core/MathItem.js';
import { OptionList } from '../../util/Options.js';
import { JaxList } from './Menu.js';
import { localize } from './__locales__/Component.js';
import { ExplorerMathItem } from '../../a11y/explorer.js';

import {
Expand Down Expand Up @@ -167,7 +168,9 @@ export class MJContextMenu extends ContextMenu {
const input = this.mathItem.inputJax.name;
const original = this.findID('Show', 'Original');
original.content =
input === 'MathML' ? 'Original MathML' : input + ' Commands';
input === 'MathML'
? localize('OriginalMathML')
: localize('Commands', input);
const clipboard = this.findID('Copy', 'Original');
clipboard.content = original.content;
}
Expand All @@ -187,26 +190,26 @@ export class MJContextMenu extends ContextMenu {
*/
protected getSpeechMenu() {
const speech = this.mathItem.outputData.speech;
this.findID('Show', 'Speech')[speech ? 'enable' : 'disable']();
this.findID('Copy', 'Speech')[speech ? 'enable' : 'disable']();
this.findID('Show', 'SpeechText')[speech ? 'enable' : 'disable']();
this.findID('Copy', 'SpeechText')[speech ? 'enable' : 'disable']();
}

/**
* Enable/disable the Braille menus
*/
protected getBrailleMenu() {
const braille = this.mathItem.outputData.braille;
this.findID('Show', 'Braille')[braille ? 'enable' : 'disable']();
this.findID('Copy', 'Braille')[braille ? 'enable' : 'disable']();
this.findID('Show', 'BrailleCode')[braille ? 'enable' : 'disable']();
this.findID('Copy', 'BrailleCode')[braille ? 'enable' : 'disable']();
}

/**
* Enable/disable the svg menus
*/
protected getSvgMenu() {
const svg = this.jax.SVG;
this.findID('Show', 'SVG')[svg ? 'enable' : 'disable']();
this.findID('Copy', 'SVG')[svg ? 'enable' : 'disable']();
this.findID('Show', 'SvgImage')[svg ? 'enable' : 'disable']();
this.findID('Copy', 'SvgImage')[svg ? 'enable' : 'disable']();
}

/**
Expand Down
Loading