-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add translations
1 parent
63dd9d3
commit 83a4c16
Showing
10 changed files
with
203 additions
and
153 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const BULLS_COLOR = "#e20613"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Font_NeueAaachen from "./assets/NeueAachenBlack.woff2"; | ||
import Font_AccidentalPresidency from "./assets/AccidentalPresidency.woff2"; | ||
import Font_Steelfish from "./assets/steelfish.woff2"; | ||
|
||
export async function loadFonts() { | ||
for (const font of [ | ||
{ name: "Neue Aachen", data: Font_NeueAaachen }, | ||
{ | ||
name: "Accidental Presidency", | ||
data: Font_AccidentalPresidency, | ||
}, | ||
{ | ||
name: "Steelfish", | ||
data: Font_Steelfish, | ||
}, | ||
]) { | ||
const fontFace = new FontFace( | ||
font.name, | ||
`url("${font.data}") format("woff2")`, | ||
); | ||
|
||
await fontFace.load(); | ||
|
||
document.fonts.add(fontFace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
export type Photo = { | ||
name: string; | ||
url: string; | ||
}; | ||
|
||
export abstract class PhotoRepository { | ||
private static PHOTOS = [ | ||
{ | ||
name: "Bulls Outfielder", | ||
url: "bulls_1.png", | ||
}, | ||
{ | ||
name: "Bulls Battery", | ||
url: "bulls_2.png", | ||
}, | ||
{ | ||
name: "Bulls Pitcher", | ||
url: "bulls_4.png", | ||
}, | ||
{ | ||
name: "Bulls Win", | ||
url: "bulls_3.png", | ||
}, | ||
{ | ||
name: "Bandidos Team", | ||
url: "bandidos_1.png", | ||
}, | ||
{ | ||
name: "Bandidos Huddle", | ||
url: "bandidos_2.png", | ||
}, | ||
{ | ||
name: "Bandidas Youth Team", | ||
url: "bandidas_1.png", | ||
}, | ||
{ | ||
name: "Barons Team", | ||
url: "barons_1.png", | ||
}, | ||
{ | ||
name: "Bullets Team", | ||
url: "bullets_1.png", | ||
}, | ||
{ | ||
name: "U8 Win", | ||
url: "u8_1.png", | ||
}, | ||
{ | ||
name: "U10 Batter", | ||
url: "u10_1.png", | ||
}, | ||
{ | ||
name: "U12 Huddle", | ||
url: "u12_1.png", | ||
}, | ||
{ | ||
name: "U14 Runner", | ||
url: "u14_1.png", | ||
}, | ||
{ | ||
name: "U16 Team", | ||
url: "u16_1.png", | ||
}, | ||
{ | ||
name: "Glove", | ||
url: "glove_1.png", | ||
}, | ||
]; | ||
|
||
public static findPhotos(): Photo[] { | ||
return PhotoRepository.PHOTOS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Photo } from "./photo-repository.ts"; | ||
import { i18n } from "./translations.ts"; | ||
|
||
function getImageUrl(name: string) { | ||
return new URL(`./assets/backgrounds/${name}`, import.meta.url).href; | ||
} | ||
|
||
export class PhotoSelect extends HTMLElement { | ||
constructor(photos: Photo[], handleSelect: (url: string) => void) { | ||
super(); | ||
|
||
const select = document.createElement("select"); | ||
|
||
select.add(new Option(`-- ${i18n("selectPhoto")} --`, "")); | ||
|
||
for (const { name, url } of photos) { | ||
select.add(new Option(name, url)); | ||
} | ||
|
||
select.addEventListener("change", () => { | ||
handleSelect(select.value ? getImageUrl(select.value) : ""); | ||
}); | ||
|
||
return select; | ||
} | ||
} | ||
|
||
window.customElements.define("photo-select", PhotoSelect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const TRANSLATIONS: { [key: string]: { [key: string]: string } } = { | ||
graphicTypeOverview: { | ||
de: "Übersicht", | ||
en: "Overview", | ||
}, | ||
graphicTypeSingle: { | ||
de: "Spiel", | ||
en: "Game", | ||
}, | ||
selectPhoto: { | ||
de: "Foto Auswählen", | ||
en: "Select Photo", | ||
}, | ||
downloadImage: { | ||
de: "Bild Herunterladen", | ||
en: "Download Image", | ||
}, | ||
uploadPhoto: { | ||
de: "Foto Hochladen", | ||
en: "Upload Photo", | ||
}, | ||
}; | ||
|
||
export function getLang() { | ||
if (navigator.languages != undefined) { | ||
return navigator.languages[0]; | ||
} | ||
|
||
return navigator.language; | ||
} | ||
|
||
const defaultLocale = "en"; | ||
const locale = getLang(); | ||
|
||
export function i18n(id: string) { | ||
if (TRANSLATIONS?.[id]?.[locale]) { | ||
return TRANSLATIONS?.[id]?.[locale]; | ||
} | ||
|
||
if (TRANSLATIONS?.[id]?.[defaultLocale]) { | ||
return TRANSLATIONS?.[id]?.[defaultLocale]; | ||
} | ||
|
||
return id; | ||
} |