Learn Practice Daily golf Reference
Text objects·Lesson 8 of 8·10 min·0/5 exercisesPro

Translate the menu

The whole of track six against the clock: the Spanish menu in JSON, HTML and Markdown, with every object from ciw to dap and the stamp on top.

Scene

Thursday, 1:00 p.m. The Little Havana kitchen opens tomorrow, and its menu goes out in Spanish: es/menu.json and its page code for the app, es/menu.html for the website, es/menu.md for the write-ups. The translations are in a chat message; putting them in is your job.

Three stops and two hours. Every value you need is wrapped in something, and you know all the wrappings now.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Make the last change again, here.
press the keys…
1 of 2
Make the last change again, here.

Every wrapping, on one card

Words and WORDs (iw iW), strings (i" a"), brackets and their layers (i( 2i(), tags (it at), sentences and paragraphs (is ap), and the stamp on top (.). Inside for the filling, around for the whole burrito.

iw
log(menu.name, find(tags, "hot"));
iW
log(menu.name, find(tags, "hot"));
i"
log(menu.name, find(tags, "hot"));
a"
log(menu.name, find(tags, "hot"));
i(
log(menu.name, find(tags, "hot"));
2i(
log(menu.name, find(tags, "hot"));
One cursor, six objects: a word, a WORD, a string and its foil, and two layers of brackets.
Boss round

Stage 1 · The app

1:05. es/menu.json, four words to translate, one at a time: "pork" becomes "cerdo", Garden Veggie becomes "Vegetariano", "vegan" becomes "vegano", and "hot" becomes "picante". Then es/menu-page.ts opens: data.en.menu is just data.menu in this file, and whatever heading gets becomes the fixed text "La carta".

Stuck? Show a hintci"cerdo<Esc> then . on the other pork tags · ci"… for each word · ciWdata.menu<Esc> · from "menu": c2i("La carta"<Esc>
1 of 8Change the red text to cerdo
1{
1 "menu": [
2 { "name": "Al Pastor", "price": 9.5, "tags": ["pork", "hot"] },
3 { "name": "Carnitas", "price": 10, "tags": ["pork"] },
4 { "name": "Garden Veggie", "price": 8.25, "tags": ["vegan"] },
5 { "name": "Birria", "price": 11, "tags": ["beef", "hot"] },
6 { "name": "Pollo Asado", "price": 9, "tags": ["chicken"] }
7 ],
8 "currency": "USD",
9 "open": [11, 23]
10}
NORMALLoading the editor…1/80.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Boss round

Stage 2 · The website

1:40. es/menu.html: the heading becomes La carta, Garden Veggie becomes Vegetariano, and the note becomes Lo picante va en rojo.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

es/menu.html, in a browserFinish the exercise above to see it.
Boss round

Stage 3 · The write-ups

2:20. es/menu.md is half done: an English sentence left over at the end of the Al Pastor line, a TODO paragraph that someone else is translating (it goes, blank line and all), and a doubled cocinado.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

From memory

The whole track, from memory

Seven situations from this week. The cursor is somewhere inside each thing.

Change this string, keeping the quotes.
scroll here, then press the keys3 keys
1 of 7
Change this string, keeping the quotes.

Extra practice optional

The chapter is done. These rounds keep going as long as you like: stop whenever it stops being useful.

Endless

Every wrapping

Endless strings, arguments, words, dotted names, tags and paragraphs, a few of each in turn.

Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.