diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..132d0eed6 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +nodejs 16.9.1 \ No newline at end of file diff --git a/Docs/Development_deployment.md b/Docs/Development_deployment.md index e163ebf79..0ef50621e 100644 --- a/Docs/Development_deployment.md +++ b/Docs/Development_deployment.md @@ -24,26 +24,27 @@ the switch ;) ). If you are using Visual Studio Code you can use a [WSL Remote](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) window, or use the Devcontainer (see more details later). -You need at least 3Gb available to run MapComplete. +You need at least 3Gb RAM available to run MapComplete, but you'll preferably have 8GB of free RAM available. To develop and build MapComplete, you 0. Make a fork and clone the repository. (We recommend a shallow clone with `git clone --filter=blob:none `) -1. Install `python3` if you do not have it already - - On linux: `sudo apt install python3` - - On windows: find the latest download on the [Python Releases for Windows page](https://www.python.org/downloads/windows/) -2. Install the nodejs version specified in [/.tool-versions](/.tool-versions) - - On linux: install npm first `sudo apt install npm`, then install `n` using npm: ` npm install -g n`, which can - then install node with `n install `. You can [use asdf to manage your runtime versions](https://asdf-vm.com/). - - Windows: install nodeJS: https://nodejs.org/en/download/ -3. Run `npm run init` which … - - runs `npm install` - - generates some additional dependencies and files -4. Run `npm run start` to host a local testversion at http://localhost:1234/index.html -5. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename` +1. Install `python3` if you do not have it already - On linux: `sudo apt install python3` +2. Install `nvm` to easily install node: + - `wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash` + - Restart your terminal + - Run `nvm install` and `nvm use` to install and use the correct version of node. (_Note: nvm might complain that the relevant version is not yet installed. It'll have it installed only for the current user account but not system-wide - which is fine) +4. Run `npm run init` (including **run**, not ~~`npm init`~~)which … + - runs `npm ci` for you + - generates some additional dependencies and files + - does various housekeeping and setup. This can take a few minutes the first time as some pngs need to be created +5. Run `npm run start` to host a local testversion at http://localhost:1234/ +6. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename` or `userlayout=true#` as [Query parameter](URL_Parameters.md). Note that the shorter URLs ( e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. +The previous instructions were tested on 2023-03-09 on a Ubuntu 22.04 machine + Development using Windows ------------------------ diff --git a/Models/ThemeConfig/LayoutConfig.ts b/Models/ThemeConfig/LayoutConfig.ts index 9ce60b479..4763169de 100644 --- a/Models/ThemeConfig/LayoutConfig.ts +++ b/Models/ThemeConfig/LayoutConfig.ts @@ -7,7 +7,7 @@ import TilesourceConfig from "./TilesourceConfig" import { ExtractImages } from "./Conversion/FixImages" import ExtraLinkConfig from "./ExtraLinkConfig" import { Utils } from "../../Utils" -import used_languages from "../../assets/generated/used_languages.json" +import LanguageUtils from "../../Utils/LanguageUtils" /** * Minimal information about a theme @@ -274,7 +274,7 @@ export default class LayoutConfig implements LayoutInformation { } total++ - used_languages.languages.forEach((ln) => { + LanguageUtils.usedLanguagesSorted.forEach((ln) => { const trans = translation.translations if (trans["*"] !== undefined) { return diff --git a/UI/LanguagePicker.ts b/UI/LanguagePicker.ts index 9babbab0a..b93cca591 100644 --- a/UI/LanguagePicker.ts +++ b/UI/LanguagePicker.ts @@ -4,9 +4,9 @@ import BaseUIElement from "./BaseUIElement" import native from "../assets/language_native.json" import language_translations from "../assets/language_translations.json" import { Translation } from "./i18n/Translation" -import used_languages from "../assets/generated/used_languages.json" import Lazy from "./Base/Lazy" import Toggle from "./Input/Toggle" +import LanguageUtils from "../Utils/LanguageUtils" export default class LanguagePicker extends Toggle { constructor(languages: string[], label: string | BaseUIElement = "") { @@ -17,7 +17,7 @@ export default class LanguagePicker extends Toggle { const normalPicker = LanguagePicker.dropdownFor(languages, label) const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label)) super(fullPicker, normalPicker, Locale.showLinkToWeblate) - const allLanguages: string[] = used_languages.languages + const allLanguages: string[] = LanguageUtils.usedLanguagesSorted } } diff --git a/UI/i18n/Translations.ts b/UI/i18n/Translations.ts index 9d6836a20..baa1b4332 100644 --- a/UI/i18n/Translations.ts +++ b/UI/i18n/Translations.ts @@ -1,13 +1,13 @@ import { FixedUiElement } from "../Base/FixedUiElement" import { Translation, TypedTranslation } from "./Translation" import BaseUIElement from "../BaseUIElement" -import known_languages from "../../assets/generated/used_languages.json" import CompiledTranslations from "../../assets/generated/CompiledTranslations" +import LanguageUtils from "../../Utils/LanguageUtils" export default class Translations { static readonly t: typeof CompiledTranslations.t & Readonly = CompiledTranslations.t - private static knownLanguages = new Set(known_languages.languages) + private static knownLanguages = LanguageUtils.usedLanguages constructor() { throw "Translations is static. If you want to intitialize a new translation, use the singular form" } diff --git a/Utils/LanguageUtils.ts b/Utils/LanguageUtils.ts index 43db28a08..9dee30cad 100644 --- a/Utils/LanguageUtils.ts +++ b/Utils/LanguageUtils.ts @@ -1,8 +1,9 @@ -import used_languages from "../assets/generated/used_languages.json" +import used_languages from "../assets/used_languages.json" export default class LanguageUtils { /** * All the languages there is currently language support for in MapComplete */ public static readonly usedLanguages: Set = new Set(used_languages.languages) + public static readonly usedLanguagesSorted: string[] = used_languages.languages } diff --git a/assets/used_languages.json b/assets/used_languages.json new file mode 100644 index 000000000..7452d7e2a --- /dev/null +++ b/assets/used_languages.json @@ -0,0 +1 @@ +{"languages":["ca","cs","da","de","en","eo","es","fi","fil","fr","gl","hu","id","it","ja","nb_NO","nl","pa_PK","pl","pt","pt_BR","ru","sl","sv","zgh","zh_Hans","zh_Hant"]} \ No newline at end of file diff --git a/scripts/generateTranslations.ts b/scripts/generateTranslations.ts index a050d9805..2fd823ef9 100644 --- a/scripts/generateTranslations.ts +++ b/scripts/generateTranslations.ts @@ -710,10 +710,7 @@ const l3 = generateTranslationsObjectFrom( const usedLanguages: string[] = Utils.Dedup(l1.concat(l2).concat(l3)).filter((v) => v !== "*") usedLanguages.sort() -fs.writeFileSync( - "./assets/generated/used_languages.json", - JSON.stringify({ languages: usedLanguages }) -) +fs.writeFileSync("./assets/used_languages.json", JSON.stringify({ languages: usedLanguages })) if (!themeOverwritesWeblate) { // Generates the core translations