Skip to content

Commit

Permalink
pkp/pkp-lib#6328 Updated localization framework
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Feb 17, 2022
1 parent 1802918 commit b84ba10
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 99 deletions.
8 changes: 2 additions & 6 deletions cache/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
*.php
*.html
*.gz
*.css
URI/
HTML/
*
!.gitignore
7 changes: 4 additions & 3 deletions classes/core/Application.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\facades\Locale;
use PKP\security\Role;

define('REQUIRES_XSL', false);
Expand All @@ -33,9 +34,6 @@

define('CONTEXT_JOURNAL', 1);

define('LANGUAGE_PACK_DESCRIPTOR_URL', 'http://pkp.sfu.ca/ojs/xml/%s/locales.xml');
define('LANGUAGE_PACK_TAR_URL', 'http://pkp.sfu.ca/ojs/xml/%s/%s.tar.gz');

define('METRIC_TYPE_COUNTER', 'ojs::counter');

class Application extends PKPApplication
Expand All @@ -49,6 +47,9 @@ public function __construct()
if (!PKP_STRICT_MODE && !class_exists('\Application')) {
class_alias('\APP\core\Application', '\Application');
}

// Add application locales
Locale::registerFolder(BASE_SYS_DIR . '/locale');
}

/**
Expand Down
49 changes: 0 additions & 49 deletions classes/i18n/AppLocale.inc.php

This file was deleted.

6 changes: 0 additions & 6 deletions classes/install/Upgrade.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ public function migrateUserAndAuthorNames()
$suffix = $row->suffix;
foreach ($supportedLocales as $siteLocale) {
$preferredPublicName = ($salutation != '' ? "${salutation} " : '') . "${firstName} " . ($middleName != '' ? "${middleName} " : '') . $lastName . ($suffix != '' ? ", ${suffix}" : '');
if (AppLocale::isLocaleWithFamilyFirst($siteLocale)) {
$preferredPublicName = "${lastName}, " . ($salutation != '' ? "${salutation} " : '') . $firstName . ($middleName != '' ? " ${middleName}" : '');
}
DB::insert(
"INSERT INTO user_settings (user_id, locale, setting_name, setting_value, setting_type) VALUES (?, ?, 'preferredPublicName', ?, 'string')",
[(int) $userId, $siteLocale, $preferredPublicName]
Expand Down Expand Up @@ -399,9 +396,6 @@ public function migrateUserAndAuthorNames()
$supportedLocales = $journalsSupportedLocales[$journalId];
foreach ($supportedLocales as $locale) {
$preferredPublicName = "${firstName} " . ($middleName != '' ? "${middleName} " : '') . $lastName . ($suffix != '' ? ", ${suffix}" : '');
if (AppLocale::isLocaleWithFamilyFirst($locale)) {
$preferredPublicName = "${lastName}, " . $firstName . ($middleName != '' ? " ${middleName}" : '');
}
DB::insert(
"INSERT INTO author_settings (author_id, locale, setting_name, setting_value, setting_type) VALUES (?, ?, 'preferredPublicName', ?, 'string')",
[(int) $authorId, $locale, $preferredPublicName]
Expand Down
7 changes: 3 additions & 4 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@
scheduled_tasks = Off

; Site time zone
; Please refer to lib/pkp/registry/timeZones.xml for a full list of supported
; Please refer to https://www.php.net/manual/en/timezones.php for a full list of supported
; time zones.
; I.e.:
; <entry key="Europe/Amsterdam" name="Amsterdam" />
; time_zone="Amsterdam"
; I.e.: "Europe/Amsterdam"
; time_zone="Europe/Amsterdam"
time_zone = "UTC"

; Short and long date formats
Expand Down
13 changes: 4 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

Open Journal Systems (OJS) has been developed by the Public Knowledge Project.
For general information about OJS and other open research systems, visit the
PKP web site at <http://pkp.sfu.ca/>.
PKP web site at <https://pkp.sfu.ca/>.s


## License
Expand Down Expand Up @@ -119,19 +119,13 @@ codes, e.g. `fr_FR`, is recommended):
* `locale/en_US`
* `lib/pkp/locale/en_US`
* `docs/manual/en`
* `registry/locale/en_US`
* `plugins/[plugin category]/[plugin name]/locale`, where applicable

The only critical files that need translation for the system to function
properly are found in `locale/en_US`, `lib/pkp/locale/en_US`, and
`registry/locale/en_US`.
properly are found in `locale/en_US`, `lib/pkp/locale/en_US`.

New locales must also be added to the file `registry/locales.xml`, after which
they can be installed in the system through the site administration web
interface.

Translations can be contributed back to PKP for distribution with future
releases of OJS.
releases of OJS at https://translate.pkp.sfu.ca/projects/.


## Scheduled Tasks
Expand Down Expand Up @@ -189,6 +183,7 @@ interpreter installed on your server.
is required for this use of this database. For details, see:
https://support.maxmind.com/geolite-legacy-discontinuation-notice/


## Contact/Support

The forum is the recommended method of contacting the team with technical
Expand Down
6 changes: 2 additions & 4 deletions docs/dev/RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ The following steps (subject to change) are typically performed to prepare a new
OJS release:


1. Ensure that the "complete" flags in registry/locales.xml are accurate. Use
the tools/genEmailUpdates.php script to generate email template update
SQL for subjects and bodies whose defaults have changed.
1. Ensure that the "complete" flags in registry/locales.xml are accurate.


2. Update version, installation, and upgrade descriptor files:
Expand All @@ -20,7 +18,7 @@ OJS release:
Commands that may be helpful in determining what bugs have been closed
since the last release (whose tag is specified in place of <last-tag>:

git log --pretty=oneline <last-tag>..HEAD # Generate a log from the last release
git log --pretty=oneline <last-tag>..HEAD # Generate a log from the last release
| egrep -o "(#|\*)([0-9]+)(#|\*)" # Look for bug IDs in the commit notes
| sed -r "s/(#|\*)//g" # Remove the octothorpes
| sort -nu # Get a unique sorted list
Expand Down
6 changes: 4 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use APP\core\Application;

/**
* @mainpage OJS API Reference
*
Expand Down Expand Up @@ -62,7 +64,7 @@

// Initialize global environment
define('INDEX_FILE_LOCATION', __FILE__);
$application = require('./lib/pkp/includes/bootstrap.inc.php');
require_once './lib/pkp/includes/bootstrap.inc.php';

// Serve the request
$application->execute();
Application::get()->execute();
15 changes: 0 additions & 15 deletions plugins/reports/counter/CounterReportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ public function register($category, $path, $mainContextId = null)
return $success;
}

/**
* @see PKPPlugin::getLocaleFilename($locale)
*/
public function getLocaleFilename($locale)
{
$localeFilenames = parent::getLocaleFilename($locale);
// Add dynamic locale keys.
foreach (glob("{$this->getPluginPath()}/locale/$locale/*.xml") as $file) {
if (!in_array($file, $localeFilenames)) {
$localeFilenames[] = $file;
}
}
return $localeFilenames;
}

/**
* @see PKPPlugin::getName()
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/search/ArticleSearchIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @brief Test class for the ArticleSearchIndex class
*/

import('classes.i18n.AppLocale'); // Causes mocked AppLocale class to be loaded
import('classes.i18n.Locale'); // Causes mocked Locale class to be loaded

import('lib.pkp.tests.PKPTestCase');

Expand Down

0 comments on commit b84ba10

Please sign in to comment.