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: docs/how_tos/i18n.rst
+4-136Lines changed: 4 additions & 136 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,143 +76,11 @@ These steps will allow your application to accept translation strings. See `fron
76
76
77
77
#. You should now be able to run your app and see everything behaving normally, with English strings.
78
78
79
-
****************
80
-
Set up Transifex
81
-
****************
82
-
83
-
In your repo, create and commit a file named ``.tx/config``::
84
-
85
-
[main]
86
-
host = https://www.transifex.com
87
-
88
-
[edx-platform.your-resource-name-here]
89
-
file_filter = src/i18n/messages/<lang>.json
90
-
source_file = src/i18n/transifex_input.json
91
-
source_lang = en
92
-
type = KEYVALUEJSON
93
-
94
-
*************************
95
-
Set up the pipeline tools
96
-
*************************
97
-
98
-
The pipeline jobs live in the `ecommerce-scripts <https://github.com/openedx/ecommerce-scripts/tree/master/transifex>`__ repo, but you don't have to modify them. They will interact with your repo through ``make`` targets.
99
-
100
-
#. Copy the `frontend-app-account Makefile <https://github.com/openedx/frontend-app-account/blob/master/Makefile>`__ to your project.
101
-
102
-
* Modify the ``transifex_resource`` variable with your own Transifex resource name.
103
-
104
-
#. The job to push strings to Transifex will call ``make push_translations`` in your repo. This target should do everything necessary to extract your strings, concat them into one file, and put them in ``src/i18n/transifex_input.json``. If you don't have any special requirements, you can just use the default target that is included ``from frontend-i18n``.
105
-
106
-
#. Extraction: We will be using a Babel plugin to find all the strings inside a ``FormattedMessage`` component or inside a call to ``defineMessages``.
* Add ``babel-plugin-formatjs`` to your dev dependencies::
123
-
124
-
npm install babel-plugin-formatjs --save-dev
125
-
126
-
* Add this to ``.babelrc``::
127
-
128
-
"env": {
129
-
"i18n": {
130
-
"plugins": [
131
-
["react-intl", {
132
-
"messagesDir": "./temp/babel-plugin-formatjs",
133
-
"moduleSourceName": "@edx/frontend-platform/i18n"
134
-
}]
135
-
]
136
-
}
137
-
}
138
-
139
-
Then:
140
-
141
-
* Confirm that running ``make i18n.extract`` creates a lot of ``.json`` files in ``your-repo/temp/babel-plugin-formatjs/`` .
142
-
143
-
* Add ``temp`` and ``src/i18n/transifex_input.json`` to your ``.gitignore``.
144
-
145
-
#. Concatenation: All those ``.json`` files need to become one file.
146
-
147
-
* Confirm that running ``make i18n.concat`` creates ``src/i18n/transifex_input.json``, which should be a file of message id / English pairs.
148
-
149
-
* If you are missing any dependencies, like ``glob``, you will need to add these to your dev dependencies.
150
-
151
-
#. Uploading comments: The ``KEYVALUEJSON`` format doesn't have a way to put in translator comments (the ``description`` field in your message definitions), so we work around this by making calls to the Transifex API. There isn't a bulk call available, so it will be one API call per string. (...I know.) As of June 2019, the rate limit is 6000 calls per hour.
152
-
153
-
* Add ``reactifex`` to your dev dependencies::
154
-
155
-
npm install reactifex --save-dev
156
-
157
-
* You can't test this one without Transifex credentials, so at this point it's probably easiest to just make your pipeline job and run that.
158
-
159
-
#. The job to pull translations out of Transifex and commit them to your repo will call ``make pull_translations``.
160
-
161
-
* If the languages you want to pull down differ from the default set, you can update the ``transifex_langs`` variable in your local Makefile.
162
-
163
-
* The user ``edx_transifex_bot`` will need to have permissions to merge an unreviewed pull request into your repo. This means your repo must either allow merging unreviewed pull requests for everyone, or ``edx_transifex_bot`` needs to be an administrator.
164
-
165
-
*******************************************
166
-
Create empty translation files in your repo
167
-
*******************************************
168
-
169
-
#. You must commit an empty language file for each language, or the ``pull`` job will fail. Each file is named ``src/i18n/messages/LANG_CODE.json`` and consists of an empty JSON object (``{}``). See this `example code with empty language files <https://github.com/openedx/frontend-component-footer/commit/46772ecc0e8de2ce1815607fdf2e8f2867dc83cf>`__.
170
-
171
-
***********************************
172
-
Create your pipeline job on Jenkins
173
-
***********************************
174
-
175
-
#. Test your change locally.
176
-
177
-
* __NOTE__: You need the existing project resource on Transifiex or have the priviledge to create it. Otherwise skip to the next step.
* Install requirements based on the ``requirements`` section on the `tools-edx-jenkins/translation-jobs.yml <https://github.com/edx/edx-internal/blob/master/tools-edx-jenkins/translation-jobs.yml>`__. It should be something similiar to ``pip install -r transifex/requirements/microfrontend-common.txt``.
184
-
185
-
* Run the script that you try to create the jobs.
186
-
187
-
* Examples: ``python transifex/pull.py https://github.com/openedx/edx-platform.git``. You might be required to setup environment variable ``GITHUB_ACCESS_TOKEN`` with your personal github account.
188
-
189
-
* For ``push_translations``, you also need transifex authentication. This action will try to create project resource if it isn't existed yet. If you don't have permission, it will fail.
190
-
191
-
* For ``pull_translations``, it should try to create a pull request and merge it to the repo.
192
-
193
-
#. In the ``edx-internal`` repo, add your job to `tools-edx-jenkins/translation-jobs.yml <https://github.com/edx/edx-internal/blob/master/tools-edx-jenkins/translation-jobs.yml>`__, using one of the existing frontend apps as a model.
194
-
195
-
* Add an opsgenie email address that actually exists :-) so you get notified of failures.
196
-
197
-
* You will need to set up OpsGenie to properly send these alerts, and to auto-close notifications when Jenkins goes back to normal.
198
-
199
-
* In the command lines that run the job, put in your repo name and the GitHub team name that you'd like notifications sent to.
200
-
201
-
* The existing jobs push translation strings to Transifex daily, and pull completed translations once a week, on Sunday. You can pick your own schedule on the ``cron`` line. It's best to move your new job off of 8PM UTC, so we don't have to worry about the Transifex API rate limit described above.
202
-
203
-
* Note that the Jenkins machine uses UTC.
204
-
205
-
#. Open a pull request with your change. If you do't have permission or someone to review, you can `open a devops ticket <https://openedx.atlassian.net/servicedesk/customer/portal/3>`_ requesting them to review your pull request and rerun the seed job. Only devops can merge pull requests in this repo.
206
-
207
-
#. Once the change get merge, you can build https://tools-edx-jenkins.edx.org/job/Seed%20Jobs/job/Translation%20Seed%20Jobs/ to have the change propegated. (You need to connect to the edX VPN)
208
-
209
-
* If you don't have permission, you can wait for the job to propegate. It takes up to one day.
210
-
211
-
#. Connect to the edX VPN to see your two new jobs at https://tools-edx-jenkins.edx.org/job/translations/ . ``push_translations`` extracts the strings from your repo and pushes them to Transifex. ``pull_translations`` pulls the translated strings from Transifex and checks them into your repo. You can test these jobs out by running them manually.
212
-
213
-
* The first job you need to run is ``push_translations``. This would create project resource on Transifex if the resource isn't existed yet.
79
+
*************************************************
80
+
Add your application to the translations workflow
81
+
*************************************************
214
82
215
-
* If you can't see this page, you might need to be added to the ``jenkins-tools-translation-jobs`` team in GitHub.
83
+
Follow the `instructions for including React repositories in the translations workflow <https://docs.openedx.org/en/latest/developers/how-tos/enable-translations-new-repo.html#react-repos>`_ on `docs.openedx.org <https://docs.openedx.org/>`_.
0 commit comments