mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 06:45:24 +01:00
* create and use namespace-i18n-plugin.ts * Changes to src/utils.ts to ensure correct importing by Vite plugins and extraction of the amespaceMap constant to its own file. * Added more comments for create help a new namespace * create utils-plugins.ts and more docs * console info appearance * chore: handle merge conflicts * chore: run biome * add biome to namespace map dropped after merge --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import path from "path"; // vite externalize in production, see https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility
|
|
|
|
/**
|
|
* Maps namespaces that deviate from the file-name
|
|
*
|
|
* @remarks expects file-name as value and custom-namespace as key
|
|
*/
|
|
export const namespaceMap = {
|
|
titles: "trainer-titles",
|
|
moveTriggers: "move-trigger",
|
|
abilityTriggers: "ability-trigger",
|
|
battlePokemonForm: "pokemon-form-battle",
|
|
miscDialogue: "dialogue-misc",
|
|
battleSpecDialogue: "dialogue-final-boss",
|
|
doubleBattleDialogue: "dialogue-double-battle",
|
|
splashMessages: "splash-texts",
|
|
mysteryEncounterMessages: "mystery-encounter-texts",
|
|
biome: "biomes",
|
|
};
|
|
|
|
/**
|
|
* Swap the value with the key and the key with the value
|
|
* @param json type {[key: string]: string}
|
|
* @returns [value]: key
|
|
*
|
|
* @source {@link https://stackoverflow.com/a/23013726}
|
|
*/
|
|
export function objectSwap(json: { [key: string]: string }): { [value: string]: string } {
|
|
const ret = {};
|
|
for (const key in json) {
|
|
ret[json[key]] = key;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
export function isFileInsideDir(file: string, dir: string): boolean {
|
|
const filePath = path.normalize(file);
|
|
const dirPath = path.normalize(dir);
|
|
return filePath.startsWith(dirPath);
|
|
}
|