Skip to content

Commit 3a9c952

Browse files
authored
Update README.md
1 parent 1af4e8d commit 3a9c952

File tree

1 file changed

+53
-52
lines changed

1 file changed

+53
-52
lines changed

README.md

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call
2121

2222
2. Install global Node modules:
2323

24-
```
24+
```bash
2525
npm install -g bunyan gulp@4
2626
```
2727

@@ -31,7 +31,7 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call
3131

3232
4. Clone the tutorial server into it:
3333

34-
```
34+
```bash
3535
cd /js
3636
git clone https://github.com/javascript-tutorial/server
3737
git clone https://github.com/javascript-tutorial/engine server/modules/engine
@@ -45,7 +45,7 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call
4545
4646
The English version is `en.javascript.info`.
4747
48-
```
48+
```bash
4949
cd /js
5050
git clone https://github.com/javascript-tutorial/en.javascript.info
5151
```
@@ -54,14 +54,14 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call
5454
5555
Install local modules:
5656
57-
```
57+
```bash
5858
cd /js/server
5959
npm install
6060
```
6161
6262
Run the site with the same language. Above we cloned `en` tutorial, so:
6363
64-
```
64+
```bash
6565
./edit en
6666
```
6767
@@ -85,53 +85,20 @@ You can set another language it with the second argument of `edit`.
8585
8686
E.g. if you cloned `ru` tutorial, it makes sense to use `ru` locale for the server as well:
8787
88-
```
88+
```bash
8989
cd /js/server
9090
./edit ru ru
9191
```
9292
9393
Please note, the server must support that language. There must be corresponding locale files for that language in the code of the server, otherwise it exists with an error. As of now, `ru`, `en`, `zh` and `ja` are fully supported.
9494
95-
# Dev mode
96-
97-
If you'd like to edit the server code (assuming you're familiar with Node.js), *not* the tutorial text, then there are two steps to do.
98-
99-
First, run the command that imports (and caches) the tutorial:
100-
101-
```
102-
cd /js/server
103-
NODE_LANG=en TUTORIAL_ROOT=/js/en.javascript.info npm run gulp engine:koa:tutorial:import
104-
```
105-
106-
For Windows: `npm i -g cross-env` and prepend the call with `cross-env` to pass environment variables, like this:
107-
108-
```
109-
cd /js/server
110-
cross-env NODE_LANG=en...
111-
```
112-
113-
In the code above, `NODE_LANG` sets server language, while `TUTORIAL_ROOT` is the full path to tutorial repo, by default is `/js/$NODE_LANG.javascript.info`.
114-
115-
Afterwards, call `./dev <server language>` to run the server:
116-
117-
```
118-
cd /js/server
119-
./dev en
120-
```
121-
122-
Running `./dev` uses the tutorial that was imported and cached by the previous command.
123-
124-
It does not "watch" tutorial text, but it reloads the server after code changes.
125-
126-
Again, that's for developing the server code itself, not writing the tutorial.
127-
12895
# Translating images
12996
13097
Most pictures are in SVG format. Strings inside it are usually just text, they can be replaced.
13198
13299
That's great, as there are many strings in English in images, like tips, notes, etc. They look nice when translated.
133100

134-
Image translations reside in `images.yml` file in the repository root, for example: <https://github.com/javascript-tutorial/ru.javascript.info/blob/master/images.yml>
101+
Image translations reside in `images.yml` file in the repository root, for example: <https://github.com/javascript-tutorial/ru.javascript.info/blob/master/images.yml>. Please, create it if needed.
135102

136103
The file format is called "YAML", it's quite easy to understand:
137104
@@ -160,33 +127,67 @@ The translated string may become longer or shorter. If we have nice pictures, st
160127
你好世界
161128
```
162129
130+
After `images.yaml` is ready, to apply translations:
163131
132+
1. Setup upstream (if you haven't yet) and pull latest changes:
133+
```bash
134+
cd /js/zh.javascript.info
135+
git remote add upstream https://github.com/javascript-tutorial/en.javascript.info
136+
git fetch upstream master
137+
```
138+
2. Run the translation task:
139+
```bash
140+
cd /js/server
141+
# without --image it applies all translations (to all images)
142+
NODE_LANG=zh glp engine:koa:tutorial:figuresTranslate --image try-catch-flow.svg
143+
```
144+
145+
The task takes upstream image (English version) and replaces strings to it.
164146

147+
In order for positioning to work, you need to have ImageMagick installed: <https://imagemagick.org/script/download.php> (or use packages for Linux/MacOS).
148+
165149
## Extract strings
166150

167-
The task to get all strings from an image (for translation, to add to `images.yml`):
151+
The task to get all strings from an image as YAML (for translation, to add to `images.yml`):
168152
```
169153
cd /js/server
170-
NODE_LANG=ru npm run gulp engine:koa:tutorial:imageYaml --image hello.svg
154+
NODE_LANG=zh npm run gulp engine:koa:tutorial:imageYaml --image hello.svg
171155
```
156+
172157

158+
# Dev mode
173159

174-
# Importing images
160+
If you'd like to edit the server code (assuming you're familiar with Node.js), *not* the tutorial text, then there are two steps to do.
175161

176-
If you modify `figures.sketch` file with pictures (need Mac and Sketch editor installed for that), images are re-imported automatically by `./edit` script.
162+
First, run the command that imports (and caches) the tutorial:
177163

178-
To do that manually:
179-
```
180-
cd /js/server
181-
NODE_LANG=ru npm run gulp engine:koa:tutorial:figuresImport
182-
```
164+
```bash
165+
cd /js/server
166+
NODE_LANG=en TUTORIAL_ROOT=/js/en.javascript.info npm run gulp engine:koa:tutorial:import
167+
```
183168

184-
You only need to re-import images if you change them, or change their translations in `images.yml`.
169+
For Windows: `npm i -g cross-env` and prepend the call with `cross-env` to pass environment variables, like this:
185170

186-
To do that, you need to have Mac and Sketch editor installed.
171+
```bash
172+
cd /js/server
173+
cross-env NODE_LANG=en...
174+
```
187175

176+
In the code above, `NODE_LANG` sets server language, while `TUTORIAL_ROOT` is the full path to tutorial repo, by default is `/js/$NODE_LANG.javascript.info`.
177+
178+
Afterwards, call `./dev <server language>` to run the server:
179+
180+
```bash
181+
cd /js/server
182+
./dev en
183+
```
184+
185+
Running `./dev` uses the tutorial that was imported and cached by the previous command.
186+
187+
It does not "watch" tutorial text, but it reloads the server after code changes.
188+
189+
Again, that's for developing the server code itself, not writing the tutorial.
188190
189-
190191
# Troubleshooting
191192
192193
Please ensure you have Node.js version 10+ (`node -v` shows the version).

0 commit comments

Comments
 (0)