How can I use last name of author in the mail template?

I would like to know how to use the last name of author in email template.
— Hiroshi

Hi @kawasaki,

Which email template are you working with? Which of our applications are you using, and what version?

Regards,
Alec Smecher
Public Knowledge Project Team

Dear Alec,

Thank you for your reply.

We are using OJS-2.4.8-1.
All email templates.
The variables handling name (user, author, etc) uses “firstName (space)
lastName” convention. E-mail in Japanese looks funny, since we use "
lastName firstName" convention.
Registration requires firstName and lastName, separately. We want to
use the variables for firstName and lastName in email templates.

Best Wishes!

— Hiroshi

The signature is formed by PKPUser::getContactSignature(), and for the name, this calls:

One of the suggested topics for the upcoming fall 2016 development sprint is internationalization of names. If you have suggestions for best practices or considerations in this area, feel free to post them here or join in at the sprint. Remote participants are welcome.

Dear Clinton,

Thank you for your suggestion.

I am a novice of the forum and have little skills for php.

Just looking a code, I am supposed to edit every php code handling mail templates. How can I find the php corresponding to each mail template?

For email template, variables (shortcodes) of firstName and lastName for each name (author, editor, reader, etc) is useful. We use them an appropriate way in each email template for each language.

For database consistency, we should have fields for name with English convention.

— Hiroshi

Dear Clinton,

I am setting up bilingual journal sit using OJS-2.4.8-1.

I realized name issue is global problem, not just e-mail template.

In the view for contents of each volume, author name appears. In our journal, author name wil appear in Japanese or in English. They are mixed in the contents.

$lastFirst tag should have selected already when the name registered.

One ideas is to check the appearance of $name variable at the registration.

Display $name and check box for a correct appearance might work.

I don’t know the structure of OJS. The database of each person can hold $lastFirst or corrected $name.

Thank you.

— Hiroshi

Yes, currently OJS is simply not suited to handle this situation correctly. The internationalization of the name will need to accommodate the users choice (or something similar) of name ordering. Note that the $lastFirst parameter for getFullName() won’t correctly display the name for your situation. It is reordering the name for citation style.

You might get part of the way there by changing the translation of “Last Name” and “First Name” in the jp_JP locale. Instead of translating “Last Name” to “Surname”, if you translated it literally as the “Last” name, this would work for internal display in OJS. Unfortunately, this would unconventionally mix surnames and given names as you browse users, and would also break the PubMed plugin, the LDAP Auth plugin, and perhaps other plugins which expect the “last name” to be the “surname”.

Alternately, if you have someone with PHP experience and if you have a way of guessing whether a particular name is English or Japanese (perhaps your Japanese authors are not generally using rōmaji for name entry?), one change to the getFullName() function would probably resolve the majority of this issue for you. For example (untested):

if (preg_match('/\p{Hiragana}|\p{Katakana}|\p{Han}/u', $lastName.$firstName) {
    $surName = $firstName;
    $firstName = $lastName;
    $lastName = $surName;
}

Dear Clinton,

Thank you for your suggestions.

I edited PKPUser.inc.php file. See the changes at the bottom of this mail.

E-mail templates and the list of editors look fine with this change. However, I have the same problem in Submission page. I still see firstName lastName convention in Japanese in Submission page.

Could you please show me the script handing names (authors, editors etc) in this page?

Thank you again.

— Hiroshi


    function getFullName($lastFirst = false) {
        mb_regex_encoding('utf-8');
        mb_internal_encoding('utf-8');
        $salutation = $this->getData('salutation');
        $firstName = $this->getData('firstName');
        $middleName = $this->getData('middleName');
        $lastName = $this->getData('lastName');
        $suffix = $this->getData('suffix');

        $firstName = mb_convert_kana($firstName, 'KVa', 'utf8');
        $lastName = mb_convert_kana($lastName, 'KVa', 'utf8');

        if ($lastFirst) {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firstName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return "$lastName, " . ($salutation != ''?"$salutation ":'') . "$firstName" . ($middleName != ''?" $middleName":'');
            }
        } else {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firtsName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return ($salutation != ''?"$salutation ":'') . "$firstName " . ($middleName != ''?"$middleName ":'') . $lastName . ($suffix != ''?", $suffix":'');
            }
        }
    }

Dear Clinton,

I have problems in the page of Submissions.

There are two types of problems. One is for Author, the other is Reviewer or Editor.

I found two possible php script.

PKPAuthor.inc.php in pkp/classes/submission/

and

PKPReviewAssignmentDAO.inc.php in pkp/classes/submission/reviewerAssignment

Could you please give comments for the change shown as follows.

Regards,

— Hiroshi

PKPAuthor.in.php, function will be replaced with

    function getFullName($lastFirst = false) {
        mb_regex_encoding('utf-8');
        mb_internal_encoding('utf-8');
        $firstName = $this->getData('firstName');
        $middleName = $this->getData('middleName');
        $lastName = $this->getData('lastName');
        $suffix = $this->getData('suffix');

        $firstName = mb_convert_kana($firstName, 'KVa', 'utf8');
        $lastName = mb_convert_kana($lastName, 'KVa', 'utf8');

        if ($lastFirst) {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firstName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return "$lastName, " . "$firstName" . ($middleName != ''?" $middleName":'');
            }
        } else {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firtsName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return "$firstName " . ($middleName != ''?"$middleName ":'') . $lastName . ($suffix != ''?", $suffix":'');
            }
        }
    }

PKPReviewAssignmentDAO.inc.php, function will be changed

    function &_fromRow(&$row) {
        mb_regex_encoding('utf-8');
        mb_internal_encoding('utf-8');
        $firstName = $row['firstName'];
        $lastName = $row['lastName'];
        $firstName = mb_convert_kana($firstName, 'KVa', 'utf8');
        $lastName = mb_convert_kana($lastName, 'KVa', 'utf8');

        $reviewAssignment = $this->newDataObject();

        $reviewAssignment->setId($row['review_id']);
        $reviewAssignment->setSubmissionId($row['submission_id']);
        $reviewAssignment->setReviewerId($row['reviewer_id']);

        if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firstName.$lastName)){
            $reviewAssignment->setReviewerFullName($lastName.' '.$firstName);
        }
        else{
            $reviewAssignment->setReviewerFullName($row['first_name'].' '.$row['last_name']);
        }

        $reviewAssignment->setCompetingInterests($row['competing_interests']);
        $reviewAssignment->setRegretMessage($row['regret_message']);
        $reviewAssignment->setRecommendation($row['recommendation']);
        $reviewAssignment->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
        $reviewAssignment->setDateNotified($this->datetimeFromDB($row['date_notified']));
        $reviewAssignment->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
        $reviewAssignment->setDateCompleted($this->datetimeFromDB($row['date_completed']));
        $reviewAssignment->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
        $reviewAssignment->setDateDue($this->datetimeFromDB($row['date_due']));
        $reviewAssignment->setDateResponseDue($this->datetimeFromDB($row['date_response_due']));
        $reviewAssignment->setLastModified($this->datetimeFromDB($row['last_modified']));
        $reviewAssignment->setDeclined($row['declined']);
        $reviewAssignment->setReplaced($row['replaced']);
        $reviewAssignment->setCancelled($row['cancelled']);
        $reviewAssignment->setReviewerFileId($row['reviewer_file_id']);
        $reviewAssignment->setQuality($row['quality']);
        $reviewAssignment->setDateRated($this->datetimeFromDB($row['date_rated']));
        $reviewAssignment->setDateReminded($this->datetimeFromDB($row['date_reminded']));
        $reviewAssignment->setReminderWasAutomatic($row['reminder_was_automatic']);
        $reviewAssignment->setRound($row['round']);
        $reviewAssignment->setReviewRevision($row['review_revision']);
        $reviewAssignment->setReviewFormId($row['review_form_id']);
        $reviewAssignment->setReviewRoundId($row['review_round_id']);
        $reviewAssignment->setReviewMethod($row['review_method']);
        $reviewAssignment->setStageId($row['stage_id']);
        $reviewAssignment->setUnconsidered($row['unconsidered']);

        return $reviewAssignment;
    }

The purpose of $lastFirst is to stylize the name as: “Surname, comma, firstname, etc.”, You don’t have that comma in your PKPAuthor::getFullName() change:

            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firstName.$lastName)){
                return "$lastName "."$firstName";
            }

You are also ignoring the $middleName entry, if it exists.

If this is intentional, then that is fine… the display is up to you.

Thank you.

I need to edit four php scripts.

Three in lib/PKP/class, the other is in class

PKPReviewAssignmentDAO.inc.php

PKPAuthor.inc.php

PKPUser.inc.php

EditAssignmentDAO.inc.php

The appearance of each page is now acceptable for us.

— Hiroshi

I have another problem.

I see the following at the notification page.

12 9月 2016 01:06:55 URL 参照http://sabsnpo.ihostfull.com/ojs-2.4.8/index.php/SABS_NL/editor/submission/7 削除http://sabsnpo.ihostfull.com/ojs-2.4.8/index.php/SABS_NL/notification/delete/40

新しい論文, “{$param}”, が投稿された時

Something is wrong for the handling “{$param}”.

Where is this template?

Double quote (") may work bad?

Thank you.

— Hiroshi

Is this variable related to the changes you have made for the name display? I suspect this is not.

If it is a different problem, please open a new topic on the forum with a title that describes this new issue. That will help keep the conversations organized and help others with similar problems in the future.

Dear Clinton,

It is NOT related to the name display.

I found {$param} should be {$title} in locale.xml of locale/ja_JP folder.

This fixed the problem.

Thank you.

— Hiroshi

I have opened an issue for the use of $param where $title is expected here:

Dear Clinton,

Today, I upgraded OJS from 2.4.8 to 3.1.
I encountered the old trouble.
In the article list, author name are shown in the order first name then last name.
I fixed this problem by editing PHP files, PKPUser.inc.php, PKPAuthor.inc.php in pkp/classes/submission/ and PKPReviewAssignmentDAO.inc.php in pkp/classes/submission/reviewerAssignment.

 if ($lastFirst) {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firstName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return "$lastName, " . "$firstName" . ($middleName != ''?" $middleName":'');
            }
        } else {
            if (preg_match("/^[ぁ-んーァ-ヶー一-龠]+$/u", $firtsName.$lastName)){
                return "$lastName "."$firstName";
            }
            else{
                return "$firstName " . ($middleName != ''?"$middleName ":'') . $lastName . ($suffix != ''?", $suffix":'');
            }
        }

In OJS 3, which files are responsible for this problem, the sequence of first name and last name.

Wishes,

— Hiroshi Kawasaki

See the Identity class’s getFullName() method:

lib/pkp/classes/identity/Identity.inc.php