You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,14 +54,14 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call
54
54
55
55
Install local modules:
56
56
57
-
```
57
+
```bash
58
58
cd /js/server
59
59
npm install
60
60
```
61
61
62
62
Run the site with the same language. Above we cloned `en` tutorial, so:
63
63
64
-
```
64
+
```bash
65
65
./edit en
66
66
```
67
67
@@ -85,53 +85,20 @@ You can set another language it with the second argument of `edit`.
85
85
86
86
E.g. if you cloned `ru` tutorial, it makes sense to use `ru` locale for the server as well:
87
87
88
-
```
88
+
```bash
89
89
cd /js/server
90
90
./edit ru ru
91
91
```
92
92
93
93
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.
94
94
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
-
128
95
# Translating images
129
96
130
97
Most pictures are in SVG format. Strings inside it are usually just text, they can be replaced.
131
98
132
99
That's great, as there are many strings in English in images, like tips, notes, etc. They look nice when translated.
133
100
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.
135
102
136
103
The file format is called "YAML", it's quite easy to understand:
137
104
@@ -160,33 +127,67 @@ The translated string may become longer or shorter. If we have nice pictures, st
160
127
你好世界
161
128
```
162
129
130
+
After `images.yaml` is ready, to apply translations:
163
131
132
+
1. Setup upstream (if you haven't yet) and pull latest changes:
The task takes upstream image (English version) and replaces strings to it.
164
146
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
+
165
149
## Extract strings
166
150
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`):
168
152
```
169
153
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
171
155
```
156
+
172
157
158
+
# Dev mode
173
159
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.
175
161
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:
177
163
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
+
```
183
168
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:
185
170
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
+
```
187
175
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.
188
190
189
-
190
191
# Troubleshooting
191
192
192
193
Please ensure you have Node.js version 10+ (`node -v` shows the version).
0 commit comments