Skip to content

Commit 1e1efec

Browse files
committed
HFP-2652 Add functions for getting translations
1 parent e08a338 commit 1e1efec

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

h5peditor-ajax.class.php

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ abstract class H5PEditorEndpoints {
3434
* Endpoint for uploading files used by the editor.
3535
*/
3636
const FILES = 'files';
37+
38+
/**
39+
* Endpoint for retrieveing translation files
40+
*/
41+
const TRANSLATIONS = 'translations';
3742
}
3843

3944

@@ -123,6 +128,11 @@ public function action($endpoint) {
123128
if (!$this->isValidEditorToken($token)) return;
124129
$this->fileUpload($contentId);
125130
break;
131+
132+
case H5PEditorEndpoints::TRANSLATIONS:
133+
$language = func_get_arg(1);
134+
H5PCore::ajaxSuccess($this->editor->getTranslations($_POST['libraries'], $language));
135+
break;
126136
}
127137
}
128138

h5peditor-ajax.interface.php

+8
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,12 @@ public function getAuthorsRecentlyUsedLibraries();
4141
*/
4242
public function validateEditorToken($token);
4343

44+
/**
45+
* Get translations for a language for a list of libraries
46+
*
47+
* @param array $libraries An array of libraries, in the form "<machineName> <majorVersion>.<minorVersion>
48+
* @param string $language_code
49+
* @return array
50+
*/
51+
public function getTranslations($libraries, $language_code);
4452
}

h5peditor.class.php

+11
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ public function getLibraries() {
129129
return $libraries;
130130
}
131131

132+
/**
133+
* Get translations for a language for a list of libraries
134+
*
135+
* @param array $libraries An array of libraries, in the form "<machineName> <majorVersion>.<minorVersion>
136+
* @param string $language_code
137+
* @return array
138+
*/
139+
public function getTranslations($libraries, $language_code) {
140+
return $this->ajaxInterface->getTranslations($libraries, $language_code);
141+
}
142+
132143
/**
133144
* Move uploaded files, remove old files and update library usage.
134145
*

0 commit comments

Comments
 (0)