Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions l10n/de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
OC.L10N.register(
"mastermind",
{
"After each guess, you get feedback about how close you were." : "Nach jedem Versuch bekommst du Rückmeldung, wie nah du dran warst.",
"And you guess:" : "Und du rätst:",
"Better luck next time" : "Mehr Glück beim nächsten Mal",
"Each day a new secret code of {length} colors is generated." : "Jeden Tag wird ein neuer geheimer Code aus {length} Farben erzeugt.",
"Example" : "Beispiel",
"Feedback" : "Rückmeldung",
"How to play?" : "Wie wird gespielt?",
"No bullet" : "Kein Punkt",
"Pick a date" : "Datum auswählen",
"Previous puzzle" : "Vorheriges Rätsel",
"Puzzle of {date}" : "Rätsel vom {date}",
"Puzzles" : "Rätsel",
"Red bullet" : "Roter Punkt",
"Submit guess" : "Versuch absenden",
"Suppose the secret code is:" : "Angenommen, der geheime Code ist:",
"The colors" : "Die Farben",
"The puzzle for {date} is not available yet." : "Das Rätsel für {date} ist noch nicht verfügbar.",
"The solution was:" : "Die Lösung war:",
"Today's puzzle" : "Rätsel von heute",
"Try again" : "Erneut versuchen",
"White bullet" : "Weißer Punkt",
"Yesterday's puzzle" : "Rätsel von gestern",
"You get {correct} red and {misplaced} white" : "Du erhältst {correct} rote und {misplaced} weiße",
"You have {attempts} attempts to guess it." : "Du hast {attempts} Versuche, ihn zu erraten.",
"You solved it!" : "Du hast es gelöst!",
"_Solved in %n guess_::_Solved in %n guesses_" : ["In %n Versuch gelöst","In %n Versuchen gelöst"],
"color not in the solution" : "Farbe kommt in der Lösung nicht vor",
"right color, right position" : "richtige Farbe, richtige Position",
"right color, wrong position" : "richtige Farbe, falsche Position"
},
"nplurals=2; plural=(n != 1);");
32 changes: 32 additions & 0 deletions l10n/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ "translations": {
"After each guess, you get feedback about how close you were." : "Nach jedem Versuch bekommst du Rückmeldung, wie nah du dran warst.",
"And you guess:" : "Und du rätst:",
"Better luck next time" : "Mehr Glück beim nächsten Mal",
"Each day a new secret code of {length} colors is generated." : "Jeden Tag wird ein neuer geheimer Code aus {length} Farben erzeugt.",
"Example" : "Beispiel",
"Feedback" : "Rückmeldung",
"How to play?" : "Wie wird gespielt?",
"No bullet" : "Kein Punkt",
"Pick a date" : "Datum auswählen",
"Previous puzzle" : "Vorheriges Rätsel",
"Puzzle of {date}" : "Rätsel vom {date}",
"Puzzles" : "Rätsel",
"Red bullet" : "Roter Punkt",
"Submit guess" : "Versuch absenden",
"Suppose the secret code is:" : "Angenommen, der geheime Code ist:",
"The colors" : "Die Farben",
"The puzzle for {date} is not available yet." : "Das Rätsel für {date} ist noch nicht verfügbar.",
"The solution was:" : "Die Lösung war:",
"Today's puzzle" : "Rätsel von heute",
"Try again" : "Erneut versuchen",
"White bullet" : "Weißer Punkt",
"Yesterday's puzzle" : "Rätsel von gestern",
"You get {correct} red and {misplaced} white" : "Du erhältst {correct} rote und {misplaced} weiße",
"You have {attempts} attempts to guess it." : "Du hast {attempts} Versuche, ihn zu erraten.",
"You solved it!" : "Du hast es gelöst!",
"_Solved in %n guess_::_Solved in %n guesses_" : ["In %n Versuch gelöst","In %n Versuchen gelöst"],
"color not in the solution" : "Farbe kommt in der Lösung nicht vor",
"right color, right position" : "richtige Farbe, richtige Position",
"right color, wrong position" : "richtige Farbe, falsche Position"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
34 changes: 34 additions & 0 deletions l10n/fr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
OC.L10N.register(
"mastermind",
{
"After each guess, you get feedback about how close you were." : "Après chaque essai, vous obtenez un retour indiquant à quel point vous étiez proche.",
"And you guess:" : "Et vous proposez :",
"Better luck next time" : "Plus de chance la prochaine fois",
"Each day a new secret code of {length} colors is generated." : "Chaque jour, un nouveau code secret de {length} couleurs est généré.",
"Example" : "Exemple",
"Feedback" : "Indices",
"How to play?" : "Comment jouer ?",
"No bullet" : "Aucun point",
"Pick a date" : "Choisissez une date",
"Previous puzzle" : "Énigme précédente",
"Puzzle of {date}" : "Énigme du {date}",
"Puzzles" : "Énigmes",
"Red bullet" : "Point rouge",
"Submit guess" : "Valider la proposition",
"Suppose the secret code is:" : "Supposons que le code secret soit :",
"The colors" : "Les couleurs",
"The puzzle for {date} is not available yet." : "L'énigme du {date} n'est pas encore disponible.",
"The solution was:" : "La solution était :",
"Today's puzzle" : "Énigme du jour",
"Try again" : "Réessayer",
"White bullet" : "Point blanc",
"Yesterday's puzzle" : "Énigme d'hier",
"You get {correct} red and {misplaced} white" : "Vous obtenez {correct} rouge et {misplaced} blanc",
"You have {attempts} attempts to guess it." : "Vous avez {attempts} tentatives pour le deviner.",
"You solved it!" : "Vous l'avez résolu !",
"_Solved in %n guess_::_Solved in %n guesses_" : ["Résolu en %n essai","Résolu en %n essais","Résolu en %n essais"],
"color not in the solution" : "couleur absente de la solution",
"right color, right position" : "bonne couleur, bonne position",
"right color, wrong position" : "bonne couleur, mauvaise position"
},
"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;");
32 changes: 32 additions & 0 deletions l10n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ "translations": {
"After each guess, you get feedback about how close you were." : "Après chaque essai, vous obtenez un retour indiquant à quel point vous étiez proche.",
"And you guess:" : "Et vous proposez :",
"Better luck next time" : "Plus de chance la prochaine fois",
"Each day a new secret code of {length} colors is generated." : "Chaque jour, un nouveau code secret de {length} couleurs est généré.",
"Example" : "Exemple",
"Feedback" : "Indices",
"How to play?" : "Comment jouer ?",
"No bullet" : "Aucun point",
"Pick a date" : "Choisissez une date",
"Previous puzzle" : "Énigme précédente",
"Puzzle of {date}" : "Énigme du {date}",
"Puzzles" : "Énigmes",
"Red bullet" : "Point rouge",
"Submit guess" : "Valider la proposition",
"Suppose the secret code is:" : "Supposons que le code secret soit :",
"The colors" : "Les couleurs",
"The puzzle for {date} is not available yet." : "L'énigme du {date} n'est pas encore disponible.",
"The solution was:" : "La solution était :",
"Today's puzzle" : "Énigme du jour",
"Try again" : "Réessayer",
"White bullet" : "Point blanc",
"Yesterday's puzzle" : "Énigme d'hier",
"You get {correct} red and {misplaced} white" : "Vous obtenez {correct} rouge et {misplaced} blanc",
"You have {attempts} attempts to guess it." : "Vous avez {attempts} tentatives pour le deviner.",
"You solved it!" : "Vous l'avez résolu !",
"_Solved in %n guess_::_Solved in %n guesses_" : ["Résolu en %n essai","Résolu en %n essais","Résolu en %n essais"],
"color not in the solution" : "couleur absente de la solution",
"right color, right position" : "bonne couleur, bonne position",
"right color, wrong position" : "bonne couleur, mauvaise position"
},"pluralForm" :"nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;"
}
34 changes: 34 additions & 0 deletions l10n/nl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
OC.L10N.register(
"mastermind",
{
"After each guess, you get feedback about how close you were." : "Na elke gok krijg je feedback over hoe dichtbij je was.",
"And you guess:" : "En je gokt:",
"Better luck next time" : "Volgende keer beter",
"Each day a new secret code of {length} colors is generated." : "Elke dag wordt een nieuwe geheime code van {length} kleuren gegenereerd.",
"Example" : "Voorbeeld",
"Feedback" : "Feedback",
"How to play?" : "Hoe speel je?",
"No bullet" : "Geen stip",
"Pick a date" : "Kies een datum",
"Previous puzzle" : "Vorige puzzel",
"Puzzle of {date}" : "Puzzel van {date}",
"Puzzles" : "Puzzels",
"Red bullet" : "Rode stip",
"Submit guess" : "Gok indienen",
"Suppose the secret code is:" : "Stel dat de geheime code is:",
"The colors" : "De kleuren",
"The puzzle for {date} is not available yet." : "De puzzel voor {date} is nog niet beschikbaar.",
"The solution was:" : "De oplossing was:",
"Today's puzzle" : "Puzzel van vandaag",
"Try again" : "Probeer opnieuw",
"White bullet" : "Witte stip",
"Yesterday's puzzle" : "Puzzel van gisteren",
"You get {correct} red and {misplaced} white" : "Je krijgt {correct} rood en {misplaced} wit",
"You have {attempts} attempts to guess it." : "Je hebt {attempts} pogingen om deze te raden.",
"You solved it!" : "Je hebt het opgelost!",
"_Solved in %n guess_::_Solved in %n guesses_" : ["Opgelost in %n poging","Opgelost in %n pogingen"],
"color not in the solution" : "kleur komt niet voor in de oplossing",
"right color, right position" : "juiste kleur, juiste positie",
"right color, wrong position" : "juiste kleur, verkeerde positie"
},
"nplurals=2; plural=(n != 1);");
32 changes: 32 additions & 0 deletions l10n/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ "translations": {
"After each guess, you get feedback about how close you were." : "Na elke gok krijg je feedback over hoe dichtbij je was.",
"And you guess:" : "En je gokt:",
"Better luck next time" : "Volgende keer beter",
"Each day a new secret code of {length} colors is generated." : "Elke dag wordt een nieuwe geheime code van {length} kleuren gegenereerd.",
"Example" : "Voorbeeld",
"Feedback" : "Feedback",
"How to play?" : "Hoe speel je?",
"No bullet" : "Geen stip",
"Pick a date" : "Kies een datum",
"Previous puzzle" : "Vorige puzzel",
"Puzzle of {date}" : "Puzzel van {date}",
"Puzzles" : "Puzzels",
"Red bullet" : "Rode stip",
"Submit guess" : "Gok indienen",
"Suppose the secret code is:" : "Stel dat de geheime code is:",
"The colors" : "De kleuren",
"The puzzle for {date} is not available yet." : "De puzzel voor {date} is nog niet beschikbaar.",
"The solution was:" : "De oplossing was:",
"Today's puzzle" : "Puzzel van vandaag",
"Try again" : "Probeer opnieuw",
"White bullet" : "Witte stip",
"Yesterday's puzzle" : "Puzzel van gisteren",
"You get {correct} red and {misplaced} white" : "Je krijgt {correct} rood en {misplaced} wit",
"You have {attempts} attempts to guess it." : "Je hebt {attempts} pogingen om deze te raden.",
"You solved it!" : "Je hebt het opgelost!",
"_Solved in %n guess_::_Solved in %n guesses_" : ["Opgelost in %n poging","Opgelost in %n pogingen"],
"color not in the solution" : "kleur komt niet voor in de oplossing",
"right color, right position" : "juiste kleur, juiste positie",
"right color, wrong position" : "juiste kleur, verkeerde positie"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
17 changes: 11 additions & 6 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<NcContent app-name="mastermind">
<NcAppNavigation>
<NcAppNavigationList>
<NcAppNavigationItem name="How to play?"
<NcAppNavigationItem :name="t('mastermind', 'How to play?')"
:active="currentView === 'howtoplay'"
@click="currentView = 'howtoplay'" />
<NcAppNavigationCaption name="Puzzles" />
<NcAppNavigationCaption :name="t('mastermind', 'Puzzles')" />
<NcAppNavigationItem v-for="entry in navEntries"
:key="entry.date"
:name="entry.label"
Expand All @@ -16,15 +16,15 @@
<div class="date-picker-section">
<NcDateTimePickerNative v-model="pickerDate"
type="date"
label="Pick a date"
:label="t('mastermind', 'Pick a date')"
:max="new Date()" />
</div>
</template>
</NcAppNavigation>
<NcAppContent>
<HowToPlay v-if="currentView === 'howtoplay'" />
<div v-else-if="isFuture" class="future-notice">
<p>The puzzle for {{ formatDate(selectedDate) }} is not available yet.</p>
<p>{{ t('mastermind', 'The puzzle for {date} is not available yet.', { date: formatDate(selectedDate) }) }}</p>
</div>
<TheGame v-else
:key="selectedDate"
Expand All @@ -36,6 +36,7 @@
</template>

<script setup lang="ts">
import { t } from '@nextcloud/l10n'
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
import NcAppNavigationCaption from '@nextcloud/vue/components/NcAppNavigationCaption'
Expand All @@ -55,7 +56,11 @@ const today = toDateString(new Date())

const navEntries = Array.from({ length: 10 }, (_, i) => {
const date = toDateString(new Date(Date.now() - i * 86_400_000))
const label = i === 0 ? 'Today\'s puzzle' : i === 1 ? 'Yesterday\'s puzzle' : `Puzzle of ${formatDate(date)}`
const label = i === 0
? t('mastermind', "Today's puzzle")
: i === 1
? t('mastermind', "Yesterday's puzzle")
: t('mastermind', 'Puzzle of {date}', { date: formatDate(date) })
return { date, label }
})

Expand All @@ -69,7 +74,7 @@ if (!hasVisited) {

const selectedTitle = computed(() => {
const entry = navEntries.find(e => e.date === selectedDate.value)
return entry ? entry.label : `Puzzle of ${formatDate(selectedDate.value)}`
return entry ? entry.label : t('mastermind', 'Puzzle of {date}', { date: formatDate(selectedDate.value) })
})

function selectDate(date: string) {
Expand Down
9 changes: 5 additions & 4 deletions src/components/EndOfGameTransition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
{{ success ? '🎉' : '😞' }}
</div>
<h2 class="game-end__title">
{{ success ? 'You solved it!' : 'Better luck next time' }}
{{ success ? t('mastermind', 'You solved it!') : t('mastermind', 'Better luck next time') }}
</h2>
<p class="game-end__subtitle">
{{ success ? `Solved in ${guessCount} ${guessCount === 1 ? 'guess' : 'guesses'}` : 'The solution was:' }}
{{ success ? n('mastermind', 'Solved in %n guess', 'Solved in %n guesses', guessCount) : t('mastermind', 'The solution was:') }}
</p>
<div class="game-end__solution-row">
<div v-for="(digit, i) in solution"
Expand All @@ -25,10 +25,10 @@
</div>
<div class="game-end__card-actions">
<button type="button" @click="emit('retry')">
Try again
{{ t('mastermind', 'Try again') }}
</button>
<button type="button" @click="emit('previous')">
Previous puzzle
{{ t('mastermind', 'Previous puzzle') }}
</button>
</div>
</div>
Expand All @@ -37,6 +37,7 @@
</template>

<script setup lang="ts">
import { n, t } from '@nextcloud/l10n'
import type { PropType } from 'vue'
import { CHOICE_COLORS } from '../utils.ts'
import type { CHOICE_ID } from '../utils.ts'
Expand Down
31 changes: 17 additions & 14 deletions src/components/HowToPlay.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<template>
<div class="how-to-play">
<h2>How to play?</h2>
<h2>{{ t('mastermind', 'How to play?') }}</h2>

<p>
Each day a new secret code of <strong>{{ CODE_LENGTH }} colors</strong> is generated.
You have <strong>{{ MAX_ATTEMPTS }} attempts</strong> to guess it.
After each guess, you get feedback about how close you were.
{{ t('mastermind', 'Each day a new secret code of {length} colors is generated.', { length: CODE_LENGTH }) }}
{{ t('mastermind', 'You have {attempts} attempts to guess it.', { attempts: MAX_ATTEMPTS }) }}
{{ t('mastermind', 'After each guess, you get feedback about how close you were.') }}
</p>

<h3>The colors</h3>
<h3>{{ t('mastermind', 'The colors') }}</h3>
<div class="color-palette">
<div v-for="(color, i) in CHOICE_COLORS"
:key="i"
class="swatch"
:style="`background: ${color}`" />
</div>

<h3>Feedback</h3>
<h3>{{ t('mastermind', 'Feedback') }}</h3>
<ul class="feedback-legend">
<li>
<span class="bullet bullet--correct" />
<span><strong>Red bullet</strong> — right color, right position</span>
<span><strong>{{ t('mastermind', 'Red bullet') }}</strong> — {{ t('mastermind', 'right color, right position') }}</span>
</li>
<li>
<span class="bullet bullet--misplaced" />
<span><strong>White bullet</strong> — right color, wrong position</span>
<span><strong>{{ t('mastermind', 'White bullet') }}</strong> — {{ t('mastermind', 'right color, wrong position') }}</span>
</li>
<li>
<span class="bullet bullet--empty" />
<span>No bulletcolor not in the solution</span>
<span>{{ t('mastermind', 'No bullet') }} — {{ t('mastermind', 'color not in the solution') }}</span>
</li>
</ul>

<h3>Example</h3>
<p>Suppose the secret code is:</p>
<h3>{{ t('mastermind', 'Example') }}</h3>
<p>{{ t('mastermind', 'Suppose the secret code is:') }}</p>
<div class="example-row">
<div v-for="(digit, i) in exampleSolution"
:key="'s' + i"
class="cell"
:style="`background: ${CHOICE_COLORS[digit]}`" />
</div>
<p>And you guess:</p>
<p>{{ t('mastermind', 'And you guess:') }}</p>
<div class="example-row">
<div v-for="(digit, i) in exampleGuess"
:key="'g' + i"
Expand All @@ -53,13 +53,16 @@
</div>
</div>
<p>
You get <strong>{{ exampleFeedback.correct }} red</strong>
and <strong>{{ exampleFeedback.misplaced }} white</strong>
{{ t('mastermind', 'You get {correct} red and {misplaced} white', {
correct: exampleFeedback.correct,
misplaced: exampleFeedback.misplaced,
}) }}
</p>
</div>
</template>

<script setup lang="ts">
import { t } from '@nextcloud/l10n'
import { CHOICE_COLORS, MAX_ATTEMPTS, judgeGuess, CODE_LENGTH } from '../utils.ts'
import type { CHOICE_ID } from '../utils.ts'

Expand Down
3 changes: 2 additions & 1 deletion src/components/TheGame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<button v-if="!solved && !failed && canSubmit"
class="submit-btn"
@click="submitGuess">
Submit guess
{{ t('mastermind', 'Submit guess') }}
</button>
<div v-else-if="!solved && !failed" class="submit-btn submit-btn--placeholder" />
<div v-if="pickerIndex !== null" class="color-picker" :style="pickerStyle">
Expand All @@ -61,6 +61,7 @@
</template>

<script setup lang="ts">
import { t } from '@nextcloud/l10n'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import {
CELL_COLORS,
Expand Down
Loading