Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the next release (3.4.0) and improved UI #16

Merged
merged 14 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ env:
- APPLICATION=ojs BRANCH=main TEST=pgsql
- APPLICATION=omp BRANCH=main TEST=mysql
- APPLICATION=omp BRANCH=main TEST=pgsql
- APPLICATION=ops BRANCH=main TEST=mysql
- APPLICATION=ops BRANCH=main TEST=pgsql

install:
# Prepare OJS/OMP/OPS environment
Expand Down
87 changes: 0 additions & 87 deletions CustomLocaleHandler.inc.php

This file was deleted.

60 changes: 60 additions & 0 deletions CustomLocaleHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* @file CustomLocaleHandler.php
*
* Copyright (c) 2016-2022 Language Science Press
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class CustomLocaleHandler
*/

namespace APP\plugins\generic\customLocale;

use APP\handler\Handler;
use Gettext\Translation;
use PKP\core\PKPRequest;
use PKP\i18n\translation\LocaleFile;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RecursiveRegexIterator;
use RegexIterator;

class CustomLocaleHandler extends Handler
{
/**
* Print the custom locale changes.
*/
public function printCustomLocaleChanges(array $args, PKPRequest $request): void
{
$customLocalePath = CustomLocalePlugin::getStoragePath();

// Get all po-files in the custom locale directory
$directory = new RecursiveDirectoryIterator($customLocalePath);
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, '/^.+\.po$/i', RecursiveRegexIterator::GET_MATCH);
$files = array_keys(iterator_to_array($regex));

header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="custom-locale.txt"');

// iterate through all customized files
foreach ($files as $localeFile) {
/** @var Translation[] */
$customTranslations = LocaleFile::loadTranslations($localeFile)->getTranslations();
if (!count($customTranslations)) {
continue;
}

$locale = explode('/', substr($localeFile, strlen($customLocalePath) + 1))[0];
$translator = CustomLocalePlugin::getTranslator($locale);
echo "${locale}\n\n";
foreach ($customTranslations as $translation) {
$localeKey = $translation->getOriginal();
echo __('common.id') . ": ${localeKey}"
. "\n" . __('plugins.generic.customLocale.file.reference') . ": {$translator->getSingular($localeKey)}"
. "\n" . __('plugins.generic.customLocale.file.custom') . ": {$translation->getTranslation()}\n\n";
}
}
}
}
181 changes: 0 additions & 181 deletions CustomLocalePlugin.inc.php

This file was deleted.

Loading