@@ -178,6 +178,9 @@ def _v0(self, project, version, build, filename):
178
178
.only ("slug" )
179
179
.order_by ("slug" )
180
180
)
181
+ project_translations = (
182
+ project .translations .all ().only ("language" ).order_by ("language" )
183
+ )
181
184
182
185
data = {
183
186
"comment" : (
@@ -250,23 +253,47 @@ def _v0(self, project, version, build, filename):
250
253
"base_page" : "" ,
251
254
},
252
255
"flyout" : {
253
- "translations" : [],
256
+ "enabled" : True ,
257
+ "translations" : [
258
+ {
259
+ # TODO: name this field "display_name"
260
+ "slug" : translation .language ,
261
+ "url" : f"/{ translation .language } /" ,
262
+ }
263
+ for translation in project_translations
264
+ ],
254
265
"versions" : [
255
266
{
267
+ # TODO: name this field "display_name"
256
268
"slug" : version .slug ,
257
269
"url" : f"/{ project .language } /{ version .slug } /" ,
258
270
}
259
271
for version in versions_active_built
260
272
],
261
- "downloads" : [],
262
- # TODO: get this values properly
263
- "vcs" : {
264
- "url" : "https://github.com" ,
265
- "username" : "readthedocs" ,
266
- "repository" : "test-builds" ,
267
- "branch" : version .identifier if version else None ,
268
- "filepath" : "/docs/index.rst" ,
269
- },
273
+ "downloads" : [
274
+ {
275
+ # TODO: name this field "display_name"
276
+ "name" : name ,
277
+ "url" : url ,
278
+ }
279
+ for name , url in version .get_downloads (pretty = True ).items ()
280
+ ],
281
+ # TODO: find a way to get this data in a reliably way.
282
+ # We don't have a simple way to map a URL to a file in the repository.
283
+ # This feature may be deprecated/removed in this implementation since it relies
284
+ # on data injected at build time and sent as `docroot=`, `source_suffix=` and `page=`.
285
+ # Example URL:
286
+ # /_/api/v2/footer_html/?project=weblate&version=latest&page=index&theme=furo&docroot=/docs/&source_suffix=.rst
287
+ # Data injected at:
288
+ # https://github.com/rtfd/readthedocs-sphinx-ext/blob/7c60d1646c12ac0b83d61abfbdd5bcd77d324124/readthedocs_ext/_templates/readthedocs-insert.html.tmpl#L23
289
+ #
290
+ # "vcs": {
291
+ # "url": "https://github.com",
292
+ # "username": "readthedocs",
293
+ # "repository": "test-builds",
294
+ # "branch": version.identifier if version else None,
295
+ # "filepath": "/docs/index.rst",
296
+ # },
270
297
},
271
298
"search" : {
272
299
"enabled" : True ,
0 commit comments