Skip to content

Commit

Permalink
Translate.translateString() no longer requires a text either
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro270707 committed Oct 29, 2023
1 parent 09dbe46 commit 631246b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions js/cookieclicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function hireWorker() {
recountCookies();
recountWorkers();
workerCost = Math.ceil(Math.pow(workerCost / 1.3, 1.2));
translate.getKeyWrapped('cookieclicker-hireworkerbutton', new LiteralText(workerCost)).then(str => {
translate.getKeyWrapped('cookieclicker-hireworkerbutton', workerCost).then(str => {
workerButtonText.innerHTML = str;
});

Expand All @@ -86,17 +86,17 @@ function upgradeClicker() {
cookieAmount -= clickerCost
recountCookies();
clickerLevel += 1;
translate.setElementString(clickerLevelCounter, new TranslatableText("cookieclicker-clickerlevel", new LiteralText(clickerLevel)));
translate.setElementString(clickerLevelCounter, new TranslatableText("cookieclicker-clickerlevel", clickerLevel));

clickerCost = Math.ceil(Math.pow(clickerCost / 1.3, 1.25));
translate.setElementString(upgradeClickerButtonText, new TranslatableText("cookieclicker-clickerlevelbutton", new LiteralText(clickerCost)));
translate.setElementString(upgradeClickerButtonText, new TranslatableText("cookieclicker-clickerlevelbutton", clickerCost));
}
}

function setCookieString(key, cookieAmount) {
translate.setElementString(cookieCounter, new TranslatableText(key, new LiteralText(cookieAmount)));
translate.setElementString(cookieCounter, new TranslatableText(key, cookieAmount));
}

function setWorkerString(key, workerAmount) {
translate.setElementString(workerCounter, new TranslatableText(key, new LiteralText(workerAmount)));
translate.setElementString(workerCounter, new TranslatableText(key, workerAmount));
}
6 changes: 3 additions & 3 deletions js/senha.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function startNewGame(pAmountOfCharacters = 5) {
victoryText.classList.add("invisible");
amountOfCharacters = pAmountOfCharacters;
randomSequence = getRandomCharacterSequence(amountOfCharacters);
translate.translateString("senha-gamestarted", new LiteralText(randomSequence)).then(str => {
translate.translateString("senha-gamestarted", randomSequence).then(str => {
console.log(str);
});
translate.setElementString(document.getElementById("valid-characters"), new TranslatableText("senha-validcharacters", new LiteralText(validCharacters)));
translate.setElementString(document.getElementById("valid-characters"), new TranslatableText("senha-validcharacters", validCharacters));
amountOfCharactersInput.max = validCharacters.length;
updateKeyboard();
addNewCharacterSlotArray();
Expand Down Expand Up @@ -157,7 +157,7 @@ document.addEventListener("keyup", (event) => {
let charactersInSlotArray = getCharacterSlotArrayAsString();
if (!charactersInSlotArray.includes(' ') && !hasDuplicateLetters(charactersInSlotArray)) {
numberOfAttempts++;
translate.setElementString(victoryText, new TranslatableText("senha-victory", new LiteralText(numberOfAttempts)));
translate.setElementString(victoryText, new TranslatableText("senha-victory", numberOfAttempts));
if (charactersInSlotArray !== randomSequence) {
addNewGuessesArray(getCorrectInWrongPlace(charactersInSlotArray), getCorrectInCorrectPlace(charactersInSlotArray));
addNewCharacterSlotArray();
Expand Down
2 changes: 1 addition & 1 deletion js/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Translate {

for (let i = 1; i <= args.length; i++) {
const placeholder = "%" + i + "$s";
if (!(args[i - 1] instanceof LiteralText || args[i - 1] instanceof TranslatableText)) continue;
if (!(args[i - 1] instanceof LiteralText || args[i - 1] instanceof TranslatableText)) args[i - 1] = new LiteralText(args[i - 1]);
const argPromise = args[i - 1].get();

if (translatedString.includes(placeholder)) {
Expand Down

0 comments on commit 631246b

Please sign in to comment.