merged i18n and i18nKeys

This commit is contained in:
Gesina Schwalbe 2021-01-26 20:47:28 +01:00
parent 62ab89f83b
commit 0b70bbf9b9
3 changed files with 8 additions and 13 deletions

View file

@ -9,16 +9,11 @@ export const DS4 = {
=============================================================================================`,
/**
* A dictionary of dictionaries each mapping keys to localized strings.
* To be filled with the localizations derived from i18nKeys.
* A dictionary of dictionaries each mapping keys to localized strings
* resp. their localization keys.
* The localization is assumed to take place on each reload.
*/
i18n: {
// to be filled with the localized mappings from i18nKeys
},
/**
* A dictionary of dictionaries each mapping keys to localization keys.
*/
i18nKeys: {
/**
* Define the set of acttack types that can be performed with weapon items
*/

View file

@ -29,8 +29,8 @@ Hooks.once("init", async function () {
CONFIG.Item.entityClass = DS4Item as typeof Item;
// Define localized type labels
CONFIG.Actor.typeLabels = DS4.i18nKeys.actorTypes;
CONFIG.Item.typeLabels = DS4.i18nKeys.itemTypes;
CONFIG.Actor.typeLabels = DS4.i18n.actorTypes;
CONFIG.Item.typeLabels = DS4.i18n.itemTypes;
// Configure Dice
CONFIG.Dice.types = [Die, DS4Check];
@ -88,8 +88,8 @@ Hooks.once("setup", function () {
const noSort = ["attributes", "traits", "combatValues", "creatureSizeCategories"];
// Localize and sort CONFIG objects
for (const o of Object.keys(CONFIG.DS4.i18nKeys)) {
const localized = Object.entries(CONFIG.DS4.i18nKeys[o]).map((e) => {
for (const o of Object.keys(CONFIG.DS4.i18n)) {
const localized = Object.entries(CONFIG.DS4.i18n[o]).map((e) => {
return [e[0], game.i18n.localize(e[1] as string)];
});
if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1]));

View file

@ -1,7 +1,7 @@
import { ModifiableData } from "../common/common-data";
import { DS4 } from "../config";
export type ItemType = keyof typeof DS4.i18nKeys.itemTypes;
export type ItemType = keyof typeof DS4.i18n.itemTypes;
export type DS4ItemDataType =
| DS4Weapon