| // |
| // Copyright 2014-25 Volker Sorge |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| /** |
| * @file Variables for sre. |
| * @author volker.sorge@gmail.com (Volker Sorge) |
| */ |
| |
| export class Variables { |
| /** |
| * SRE version. |
| */ |
| public static readonly VERSION: string = '5.0.0-rc.4'; |
| |
| /** |
| * Locale mapping to language names. |
| */ |
| public static readonly LOCALES: Map<string, string> = new Map([ |
| ['af', 'Afrikaans'], |
| ['ca', 'Catalan'], |
| ['da', 'Danish'], |
| ['de', 'German'], |
| ['en', 'English'], |
| ['es', 'Spanish'], |
| ['euro', 'Euro'], |
| ['fr', 'French'], |
| ['hi', 'Hindi'], |
| ['it', 'Italian'], |
| ['ko', 'Korean'], |
| ['nb', 'Bokmål'], |
| ['nn', 'Nynorsk'], |
| ['sv', 'Swedish'], |
| ['nemeth', 'Nemeth'] |
| ]); |
| |
| /** |
| * Ensures a locale exists. If the given locale does not exist, it returns the |
| * default instead. |
| * |
| * @param loc The locale in question. |
| * @param def A default locale. |
| * @returns The existing locale. The default is returned if `loc` does not |
| * exist. There is no further check on `def`, however! |
| */ |
| public static ensureLocale(loc: string, def: string): string { |
| if (!Variables.LOCALES.get(loc)) { |
| console.error( |
| `Locale ${loc} does not exist! Using` + |
| ` ${Variables.LOCALES.get(def)} instead.` |
| ); |
| return def; |
| } |
| return loc; |
| } |
| |
| /** |
| * MathJax version. This indicates the lowest MathJax version this version of |
| * SRE is compatible with. |
| */ |
| public static readonly mathjaxVersion: string = '4.1.2'; |
| |
| /** |
| * The URL for SRE resources. |
| */ |
| public static readonly url: string = |
| 'https://cdn.jsdelivr.net/npm/speech-rule-engine@' + |
| Variables.VERSION + |
| '/lib/mathmaps'; |
| } |