diff --git a/tsconfig.json b/tsconfig.json index b9437be..ab5500d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "strict": true, "esModuleInterop": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true } } diff --git a/utils/translationUtil.ts b/utils/translationUtil.ts index 577bdfb..6a8ca57 100644 --- a/utils/translationUtil.ts +++ b/utils/translationUtil.ts @@ -1,153 +1,12 @@ import { SupportedLanguages } from 'db/interfaces' +import es from './translations/es.json' +import fr from './translations/fr.json' type translatable = 'types' | 'rarity' | 'stage' | 'category' | 'suffix' | 'abilityType' | 'trainerType' | 'energyType' const translations: Record>> = { - es: { - abilityType: { - 'Ability': 'Habilidad', - // Missing - 'Ancient Trait': 'Ancient Trait', - // Missing - 'Poke-BODY': 'Poke-BODY', - // Missing - 'Poke-POWER': 'Poke-POWER', - // Missing - 'Pokemon Power': 'Pokemon Power' - - }, - category: { - Energy: 'Energía', - Pokemon: 'Pokémon', - Trainer: 'Entrenador' - }, - energyType: { - Normal: 'Básico', - Special: 'Especial' - }, - rarity: { - 'Amazing': 'Increíbles', - 'Common': 'Commún', - 'None': 'Ninguno', - 'Rare': 'Rara', - 'Secret Rare': 'Rara Secreto', - 'Ultra Rare': 'Rara Ultra', - 'Uncommon': 'Uncommon' - }, - stage: { - 'BREAK': 'TURBO', - 'Basic': 'Basico', - 'LEVEL-UP': 'Subir de nivel', - 'MEGA': 'MEGA', - 'RESTORED': 'Recreado', - 'Stage1': 'Fase 1', - 'Stage2': 'Fase 2', - 'VMAX': 'VMAX' - }, - suffix: { - 'EX': 'EX', - 'GX': 'GX', - 'Legend': 'LEYENDA', - 'Prime': 'Prime', - 'SP': 'SP', - 'TAG TEAM-GX': 'TAG TEAM-GX', - 'V': 'V' - }, - trainerType: { - // Missing - 'Ace Spec': 'Ace Spec', - // Missing - 'Goldenrod Game Corner': 'Goldenrod Game Corner', - 'Item': 'Objeto', - 'Rocket\'s Secret Machine': 'Máquina Secreta de Rocket', - 'Stadium': 'Estaio', - 'Supporter': 'Partidario', - 'Technical Machine': 'Máquina Técnica', - 'Tool': 'Herramienta' - }, - types: { - Colorless: 'Incolora', - Darkness: 'Oscura', - Dragon: 'Dragón', - Fairy: 'Hada', - Fighting: 'Lucha', - Fire: 'Guego', - Grass: 'Planta', - Lightning: 'Rayo', - Metal: 'Metálica', - Psychic: 'Psíquico', - Water: 'Agua' - } - }, - fr: { - abilityType: { - 'Ability': 'Talent', - 'Ancient Trait': 'Trait Antique', - 'Poke-BODY': 'Poké-BODY', - 'Poke-POWER': 'Poké-POWER', - 'Pokemon Power': 'Pouvoir Pokémon' - }, - category: { - Energy: 'Énergie', - Pokemon: 'Pokémon', - Trainer: 'Dresseur' - }, - energyType: { - Normal: 'De base', - Special: 'Spécial' - }, - rarity: { - 'Amazing': 'Magnifique', - 'Common': 'Commune', - 'None': 'Sans Rareté', - 'Rare': 'Rare', - 'Secret Rare': 'Magnifique rare', - 'Ultra Rare': 'Ultra Rare', - 'Uncommon': 'Peu Commune' - }, - stage: { - 'BREAK': 'TURBO', - 'Basic': 'De base', - 'LEVEL-UP': 'Niveau Sup', - 'MEGA': 'MÉGA', - 'RESTORED': 'Restauré', - 'Stage1': 'Niveau 1', - 'Stage2': 'Niveau 2', - 'VMAX': 'ESCOUADE' - }, - suffix: { - 'EX': 'EX', - 'GX': 'GX', - 'Legend': 'LÉGENDE', - 'Prime': 'Prime', - 'SP': 'SP', - 'TAG TEAM-GX': 'TAG TEAM-GX', - 'V': 'V' - }, - trainerType: { - 'Ace Spec': 'High-Tech', - 'Goldenrod Game Corner': 'Salle de jeu de Doublonville', - 'Item': 'Objet', - 'Rocket\'s Secret Machine': 'Machine secrète des Rocket', - 'Stadium': 'Stade', - 'Supporter': 'Supporter', - 'Technical Machine': 'Machine Technique', - 'Tool': 'Outil' - }, - types: { - Colorless: 'Incolore', - Darkness: 'Obscurité', - Dragon: 'Dragon', - Fairy: 'Fée', - Fighting: 'Combat', - Fire: 'Feu', - Grass: 'Plante', - Lightning: 'Électrique', - Metal: 'Métal', - Psychic: 'Psy', - Water: 'Eau' - } - } + es, + fr } export default function translate(item: translatable, key: string | undefined, lang: SupportedLanguages): string | undefined { diff --git a/utils/translations/es.json b/utils/translations/es.json new file mode 100644 index 0000000..c8d0d6b --- /dev/null +++ b/utils/translations/es.json @@ -0,0 +1,72 @@ +{ + "$schema": "./schema.json", + "__comment__": "Missing some abilityTypes and some Trainer Types", + "abilityType": { + "Ability": "Habilidad", + "Ancient Trait": "Ancient Trait", + "Poke-BODY": "Poke-BODY", + "Poke-POWER": "Poke-POWER", + "Pokemon Power": "Pokemon Power" + + }, + "category": { + "Energy": "Energía", + "Pokemon": "Pokémon", + "Trainer": "Entrenador" + }, + "energyType": { + "Normal": "Básico", + "Special": "Especial" + }, + "rarity": { + "Amazing": "Increíbles", + "Common": "Commún", + "None": "Ninguno", + "Rare": "Rara", + "Secret Rare": "Rara Secreto", + "Ultra Rare": "Rara Ultra", + "Uncommon": "Uncommon" + }, + "stage": { + "BREAK": "TURBO", + "Basic": "Basico", + "LEVEL-UP": "Subir de nivel", + "MEGA": "MEGA", + "RESTORED": "Recreado", + "Stage1": "Fase 1", + "Stage2": "Fase 2", + "VMAX": "VMAX" + }, + "suffix": { + "EX": "EX", + "GX": "GX", + "Legend": "LEYENDA", + "Prime": "Prime", + "SP": "SP", + "TAG TEAM-GX": "TAG TEAM-GX", + "V": "V" + }, + "trainerType": { + "Ace Spec": "Ace Spec", + "Goldenrod Game Corner": "Goldenrod Game Corner", + "Item": "Objeto", + "Rocket's Secret Machine": "Máquina Secreta de Rocket", + "Stadium": "Estaio", + "Supporter": "Partidario", + "Technical Machine": "Máquina Técnica", + "Tool": "Herramienta" + }, + "types": { + "Colorless": "Incolora", + "Darkness": "Oscura", + "Dragon": "Dragón", + "Fairy": "Hada", + "Fighting": "Lucha", + "Fire": "Guego", + "Grass": "Planta", + "Lightning": "Rayo", + "Metal": "Metálica", + "Psychic": "Psíquico", + "Water": "Agua" + } +} diff --git a/utils/translations/fr.json b/utils/translations/fr.json new file mode 100644 index 0000000..2cdba19 --- /dev/null +++ b/utils/translations/fr.json @@ -0,0 +1,70 @@ +{ + "$schema": "./schema.json", + "abilityType": { + "Ability": "Talent", + "Ancient Trait": "Trait Antique", + "Poke-BODY": "Poké-BODY", + "Poke-POWER": "Poké-POWER", + "Pokemon Power": "Pouvoir Pokémon" + }, + "category": { + "Energy": "Énergie", + "Pokemon": "Pokémon", + "Trainer": "Dresseur" + }, + "energyType": { + "Normal": "De base", + "Special": "Spécial" + }, + "rarity": { + "Amazing": "Magnifique", + "Common": "Commune", + "None": "Sans Rareté", + "Rare": "Rare", + "Secret Rare": "Magnifique rare", + "Ultra Rare": "Ultra Rare", + "Uncommon": "Peu Commune" + }, + "stage": { + "BREAK": "TURBO", + "Basic": "De base", + "LEVEL-UP": "Niveau Sup", + "MEGA": "MÉGA", + "RESTORED": "Restauré", + "Stage1": "Niveau 1", + "Stage2": "Niveau 2", + "VMAX": "ESCOUADE" + }, + "suffix": { + "EX": "EX", + "GX": "GX", + "Legend": "LÉGENDE", + "Prime": "Prime", + "SP": "SP", + "TAG TEAM-GX": "TAG TEAM-GX", + "V": "V" + }, + "trainerType": { + "Ace Spec": "High-Tech", + "Goldenrod Game Corner": "Salle de jeu de Doublonville", + "Item": "Objet", + "Rocket's Secret Machine": "Machine secrète des Rocket", + "Stadium": "Stade", + "Supporter": "Supporter", + "Technical Machine": "Machine Technique", + "Tool": "Outil" + }, + "types": { + "Colorless": "Incolore", + "Darkness": "Obscurité", + "Dragon": "Dragon", + "Fairy": "Fée", + "Fighting": "Combat", + "Fire": "Feu", + "Grass": "Plante", + "Lightning": "Électrique", + "Metal": "Métal", + "Psychic": "Psy", + "Water": "Eau" + } +} diff --git a/utils/translations/schema.json b/utils/translations/schema.json new file mode 100644 index 0000000..5403c60 --- /dev/null +++ b/utils/translations/schema.json @@ -0,0 +1,276 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "abilityType": { + "type": "object", + "properties": { + "Ability": { + "type": "string" + }, + "Ancient Trait": { + "type": "string" + }, + "Poke-BODY": { + "type": "string" + }, + "Poke-POWER": { + "type": "string" + }, + "Pokemon Power": { + "type": "string" + } + }, + "required": [ + "Ability", + "Ancient Trait", + "Poke-BODY", + "Poke-POWER", + "Pokemon Power" + ] + }, + "category": { + "type": "object", + "properties": { + "Energy": { + "type": "string" + }, + "Pokemon": { + "type": "string" + }, + "Trainer": { + "type": "string" + } + }, + "required": [ + "Energy", + "Pokemon", + "Trainer" + ] + }, + "energyType": { + "type": "object", + "properties": { + "Normal": { + "type": "string" + }, + "Special": { + "type": "string" + } + }, + "required": [ + "Normal", + "Special" + ] + }, + "rarity": { + "type": "object", + "properties": { + "Amazing": { + "type": "string" + }, + "Common": { + "type": "string" + }, + "None": { + "type": "string" + }, + "Rare": { + "type": "string" + }, + "Secret Rare": { + "type": "string" + }, + "Ultra Rare": { + "type": "string" + }, + "Uncommon": { + "type": "string" + } + }, + "required": [ + "Amazing", + "Common", + "None", + "Rare", + "Secret Rare", + "Ultra Rare", + "Uncommon" + ] + }, + "stage": { + "type": "object", + "properties": { + "BREAK": { + "type": "string" + }, + "Basic": { + "type": "string" + }, + "LEVEL-UP": { + "type": "string" + }, + "MEGA": { + "type": "string" + }, + "RESTORED": { + "type": "string" + }, + "Stage1": { + "type": "string" + }, + "Stage2": { + "type": "string" + }, + "VMAX": { + "type": "string" + } + }, + "required": [ + "BREAK", + "Basic", + "LEVEL-UP", + "MEGA", + "RESTORED", + "Stage1", + "Stage2", + "VMAX" + ] + }, + "suffix": { + "type": "object", + "properties": { + "EX": { + "type": "string" + }, + "GX": { + "type": "string" + }, + "Legend": { + "type": "string" + }, + "Prime": { + "type": "string" + }, + "SP": { + "type": "string" + }, + "TAG TEAM-GX": { + "type": "string" + }, + "V": { + "type": "string" + } + }, + "required": [ + "EX", + "GX", + "Legend", + "Prime", + "SP", + "TAG TEAM-GX", + "V" + ] + }, + "trainerType": { + "type": "object", + "properties": { + "Ace Spec": { + "type": "string" + }, + "Goldenrod Game Corner": { + "type": "string" + }, + "Item": { + "type": "string" + }, + "Rocket's Secret Machine": { + "type": "string" + }, + "Stadium": { + "type": "string" + }, + "Supporter": { + "type": "string" + }, + "Technical Machine": { + "type": "string" + }, + "Tool": { + "type": "string" + } + }, + "required": [ + "Ace Spec", + "Goldenrod Game Corner", + "Item", + "Rocket's Secret Machine", + "Stadium", + "Supporter", + "Technical Machine", + "Tool" + ] + }, + "types": { + "type": "object", + "properties": { + "Colorless": { + "type": "string" + }, + "Darkness": { + "type": "string" + }, + "Dragon": { + "type": "string" + }, + "Fairy": { + "type": "string" + }, + "Fighting": { + "type": "string" + }, + "Fire": { + "type": "string" + }, + "Grass": { + "type": "string" + }, + "Lightning": { + "type": "string" + }, + "Metal": { + "type": "string" + }, + "Psychic": { + "type": "string" + }, + "Water": { + "type": "string" + } + }, + "required": [ + "Colorless", + "Darkness", + "Dragon", + "Fairy", + "Fighting", + "Fire", + "Grass", + "Lightning", + "Metal", + "Psychic", + "Water" + ] + } + }, + "required": [ + "abilityType", + "category", + "energyType", + "rarity", + "stage", + "suffix", + "trainerType", + "types" + ] +}