chore: update documentation, fix a few issues to make a new development setup easier, fix #1343

This commit is contained in:
Pieter Vander Vennet 2023-03-09 17:11:44 +01:00
parent c11bcb1817
commit 2f56f4d9fd
8 changed files with 25 additions and 24 deletions

1
.nvmrc Normal file
View file

@ -0,0 +1 @@
nodejs 16.9.1

View file

@ -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 a [WSL Remote](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) window, or use the
Devcontainer (see more details later). 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 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 <repo>`) 0. Make a fork and clone the repository. (We recommend a shallow clone with `git clone --filter=blob:none <repo>`)
1. Install `python3` if you do not have it already 1. Install `python3` if you do not have it already - On linux: `sudo apt install python3`
- On linux: `sudo apt install python3` 2. Install `nvm` to easily install node:
- On windows: find the latest download on the [Python Releases for Windows page](https://www.python.org/downloads/windows/) - `wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash`
2. Install the nodejs version specified in [/.tool-versions](/.tool-versions) - Restart your terminal
- On linux: install npm first `sudo apt install npm`, then install `n` using npm: ` npm install -g n`, which can - 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)
then install node with `n install <node-version>`. You can [use asdf to manage your runtime versions](https://asdf-vm.com/). 4. Run `npm run init` (including **run**, not ~~`npm init`~~)which …
- Windows: install nodeJS: https://nodejs.org/en/download/ - runs `npm ci` for you
3. Run `npm run init` which … - generates some additional dependencies and files
- runs `npm install` - does various housekeeping and setup. This can take a few minutes the first time as some pngs need to be created
- generates some additional dependencies and files 5. Run `npm run start` to host a local testversion at http://localhost:1234/
4. Run `npm run start` to host a local testversion at http://localhost:1234/index.html 6. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename`
5. By default, a landing page with available themes is served. In order to load a single theme, use `layout=themename`
or `userlayout=true#<layout configuration>` as [Query parameter](URL_Parameters.md). Note that the shorter URLs ( or `userlayout=true#<layout configuration>` as [Query parameter](URL_Parameters.md). Note that the shorter URLs (
e.g. `bookcases.html`, `aed.html`, ...) _don't_ exist on the development version. 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 Development using Windows
------------------------ ------------------------

View file

@ -7,7 +7,7 @@ import TilesourceConfig from "./TilesourceConfig"
import { ExtractImages } from "./Conversion/FixImages" import { ExtractImages } from "./Conversion/FixImages"
import ExtraLinkConfig from "./ExtraLinkConfig" import ExtraLinkConfig from "./ExtraLinkConfig"
import { Utils } from "../../Utils" import { Utils } from "../../Utils"
import used_languages from "../../assets/generated/used_languages.json" import LanguageUtils from "../../Utils/LanguageUtils"
/** /**
* Minimal information about a theme * Minimal information about a theme
@ -274,7 +274,7 @@ export default class LayoutConfig implements LayoutInformation {
} }
total++ total++
used_languages.languages.forEach((ln) => { LanguageUtils.usedLanguagesSorted.forEach((ln) => {
const trans = translation.translations const trans = translation.translations
if (trans["*"] !== undefined) { if (trans["*"] !== undefined) {
return return

View file

@ -4,9 +4,9 @@ import BaseUIElement from "./BaseUIElement"
import native from "../assets/language_native.json" import native from "../assets/language_native.json"
import language_translations from "../assets/language_translations.json" import language_translations from "../assets/language_translations.json"
import { Translation } from "./i18n/Translation" import { Translation } from "./i18n/Translation"
import used_languages from "../assets/generated/used_languages.json"
import Lazy from "./Base/Lazy" import Lazy from "./Base/Lazy"
import Toggle from "./Input/Toggle" import Toggle from "./Input/Toggle"
import LanguageUtils from "../Utils/LanguageUtils"
export default class LanguagePicker extends Toggle { export default class LanguagePicker extends Toggle {
constructor(languages: string[], label: string | BaseUIElement = "") { constructor(languages: string[], label: string | BaseUIElement = "") {
@ -17,7 +17,7 @@ export default class LanguagePicker extends Toggle {
const normalPicker = LanguagePicker.dropdownFor(languages, label) const normalPicker = LanguagePicker.dropdownFor(languages, label)
const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label)) const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label))
super(fullPicker, normalPicker, Locale.showLinkToWeblate) super(fullPicker, normalPicker, Locale.showLinkToWeblate)
const allLanguages: string[] = used_languages.languages const allLanguages: string[] = LanguageUtils.usedLanguagesSorted
} }
} }

View file

@ -1,13 +1,13 @@
import { FixedUiElement } from "../Base/FixedUiElement" import { FixedUiElement } from "../Base/FixedUiElement"
import { Translation, TypedTranslation } from "./Translation" import { Translation, TypedTranslation } from "./Translation"
import BaseUIElement from "../BaseUIElement" import BaseUIElement from "../BaseUIElement"
import known_languages from "../../assets/generated/used_languages.json"
import CompiledTranslations from "../../assets/generated/CompiledTranslations" import CompiledTranslations from "../../assets/generated/CompiledTranslations"
import LanguageUtils from "../../Utils/LanguageUtils"
export default class Translations { export default class Translations {
static readonly t: typeof CompiledTranslations.t & Readonly<typeof CompiledTranslations.t> = static readonly t: typeof CompiledTranslations.t & Readonly<typeof CompiledTranslations.t> =
CompiledTranslations.t CompiledTranslations.t
private static knownLanguages = new Set(known_languages.languages) private static knownLanguages = LanguageUtils.usedLanguages
constructor() { constructor() {
throw "Translations is static. If you want to intitialize a new translation, use the singular form" throw "Translations is static. If you want to intitialize a new translation, use the singular form"
} }

View file

@ -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 { export default class LanguageUtils {
/** /**
* All the languages there is currently language support for in MapComplete * All the languages there is currently language support for in MapComplete
*/ */
public static readonly usedLanguages: Set<string> = new Set(used_languages.languages) public static readonly usedLanguages: Set<string> = new Set(used_languages.languages)
public static readonly usedLanguagesSorted: string[] = used_languages.languages
} }

View file

@ -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"]}

View file

@ -710,10 +710,7 @@ const l3 = generateTranslationsObjectFrom(
const usedLanguages: string[] = Utils.Dedup(l1.concat(l2).concat(l3)).filter((v) => v !== "*") const usedLanguages: string[] = Utils.Dedup(l1.concat(l2).concat(l3)).filter((v) => v !== "*")
usedLanguages.sort() usedLanguages.sort()
fs.writeFileSync( fs.writeFileSync("./assets/used_languages.json", JSON.stringify({ languages: usedLanguages }))
"./assets/generated/used_languages.json",
JSON.stringify({ languages: usedLanguages })
)
if (!themeOverwritesWeblate) { if (!themeOverwritesWeblate) {
// Generates the core translations // Generates the core translations