-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from OPUS4/OPUSVIER-4220
OPUSVIER-4220 Modifications for translations export/import.
- Loading branch information
Showing
3 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
* @category Framework | ||
* @package Opus | ||
* @author Jens Schwidder <[email protected]> | ||
* @copyright Copyright (c) 2018-2019, OPUS 4 development team | ||
* @copyright Copyright (c) 2018-2020, OPUS 4 development team | ||
* @license http://www.gnu.org/licenses/gpl.html General Public License | ||
*/ | ||
|
||
|
@@ -43,8 +43,12 @@ | |
* TODO is it necessary to support same key for multiple modules? | ||
* TODO how to handle same key in default and module translations is not clear yet. What if a key needs to be edited in | ||
* the administration? How to decide which module is meant? | ||
* | ||
* TODO merge getTranslations and getTranslationsByModule | ||
* This is functionality for the management user interface. The translations are always needed with the module | ||
* information. | ||
*/ | ||
class Opus_Translate_Dao | ||
class Opus_Translate_Dao implements \Opus\Translate\StorageInterface | ||
{ | ||
|
||
public function remove($key, $module = null) | ||
|
@@ -307,4 +311,44 @@ public function renameKey($key, $newKey, $module = 'default') | |
|
||
$database->commit(); | ||
} | ||
|
||
public function getTranslationsWithModules() | ||
{ | ||
$table = Opus_Db_TableGateway::getInstance('Opus_Db_Translations'); | ||
|
||
$select = $table->getAdapter()->select() | ||
->from(['t' => 'translations'], ['keys.key', 'locale', 'value', 'keys.module']) | ||
->join(['keys' => 'translationkeys'], 't.key_id = keys.id'); | ||
|
||
$rows = $table->getAdapter()->fetchAll($select); | ||
|
||
$result = []; | ||
|
||
foreach ($rows as $row) { | ||
$key = $row['key']; | ||
$locale = $row['locale']; | ||
$value = $row['value']; | ||
$module = $row['module']; | ||
|
||
$result[$key]['module'] = $module; | ||
$result[$key]['values'][$locale] = $value; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getModules() | ||
{ | ||
$table = OPus_Db_TableGateway::getInstance('Opus_Db_Translations'); | ||
|
||
$select = $table->getAdapter()->select() | ||
->from(['keys' => 'translationkeys'], ['keys.module'])->distinct(); | ||
|
||
$rows = $table->getAdapter()->fetchCol($select); | ||
|
||
return $rows; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters