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
Copy file name to clipboardExpand all lines: README.md
+28-8Lines changed: 28 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,15 +116,21 @@ Please note, the server must support that language. There must be corresponding
116
116
117
117
# Translating images
118
118
119
-
The text in SVG pictures can be translated as well.
119
+
Please don't translate SVG files manually.
120
120
121
-
There's a special script forthat. The translated strings should bein the `images.yml` file in the repository root, such as <https://github.com/javascript-tutorial/ru.javascript.info/blob/master/images.yml>. The script replaces strings in all svgs according to `images.yml`.
121
+
They are auto-generated from the English variant, with the text phrases substituted from `images.yml` file in the repository root, such as <https://github.com/javascript-tutorial/ru.javascript.info/blob/master/images.yml>.
122
+
123
+
So you need to translate the content of `images.yml` and re-generate the SVGs using a script.
122
124
123
125
Here are the steps to translate images.
124
126
125
127
**Step 1.** Create `images.yml` with translations in the repository root.
126
128
127
-
The file format is "YAML", it's quite easy to understand:
129
+
An example of such file (in Russian): https://github.com/javascript-tutorial/ru.javascript.info/blob/master/images.yml
130
+
131
+
The file format is "YAML".
132
+
133
+
Here's a quote:
128
134
129
135
```yaml
130
136
code-style.svg: # image file name
@@ -133,28 +139,42 @@ code-style.svg: # image file name
133
139
position: "center" # (optional) "center" or "right" - to position the translated string
134
140
```
135
141
136
-
**Step 2.** Setup git upstream (if you haven't yet) and pull latest changes:
142
+
As you can see, for each image file (such as `code-style.svg`), there go English phrases (such as `"No space"`).
143
+
144
+
For each phrase, there's the translated `text` and the text `position` (not always needed, details will come soon).
145
+
146
+
You can make a small file with only one image for the start.
147
+
148
+
**Step 2.** Setup git upstream (if you haven't yet) and pull latest changes from English version:
137
149
138
150
```bash
139
151
cd /js/zh.javascript.info # in the tutorial folder
NODE_LANG=zh npm run gulp -- engine:koa:tutorial:figuresTranslate
149
166
```
150
167
151
-
This script checks out all SVG images from `upstream` and replaces the strings according to `images.yml`.
168
+
This script checks out all SVG images from `upstream` (English version) and replaces the strings inside them according to `images.yml`. So they become translated.
169
+
170
+
New SVGs are the tutorial folder now, but not committed yet.
171
+
172
+
You may want to open and see them, e.g. in Chrome browser, just to ensure that the translation fits well.
152
173
153
-
Now images in the tutorial folder are translated, but not committed yet.
174
+
P.S. If an image appears untranslated on refresh, force the browser to "reload without cache" ([hotkeys](https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Bypassing_cache)).
154
175
155
-
**Step 4.** Then you'll need `git add/commit/push` the translated SVGs, as a part of the normal translation flow.
176
+
**Step 4.** Then you'll need to `git add/commit/push` the translated SVGs, as a part of the normal translation flow.
156
177
157
-
You may want to open the translated SVGs directly in the browser to take a look at them before committing. Just to make sure that the translation looks all right. If an image is untranslated on refresh, force the browser to "reload without cache" ([hotkeys](https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Bypassing_cache)).
158
178
159
179
160
180
> To translate a single image, use the `--image` parameter of the script:
0 commit comments